private static void WriteValue(BinaryWriter writer, IValue value) { // Write the value type writer.Write((uint)value.Type); switch (value.Type) { case ValueType.Table: WriteValue(writer, value.AsTable()); break; case ValueType.List: WriteValue(writer, value.AsList()); break; case ValueType.String: WriteValue(writer, value.AsString()); break; case ValueType.Integer: writer.Write(value.AsInteger()); break; case ValueType.Float: writer.Write(value.AsFloat()); break; case ValueType.Boolean: WriteValue(writer, value.AsBoolean()); break; default: throw new InvalidOperationException("Unknown ValueType"); } }
public override void Eval(ref IValue ret, IValue[] a_pArg) { Global.MUP_VERIFY(a_pArg.Length == 2); IValue argMin = a_pArg[0]; IValue argMax = a_pArg[1]; if (!argMin.IsNonComplexScalar()) { throw new ParserError(new ErrorContext(EErrorCodes.ecTYPE_CONFLICT_FUN, -1, GetIdent(), argMin.GetValueType(), 'i', 1)); } if (!argMax.IsNonComplexScalar()) { throw new ParserError(new ErrorContext(EErrorCodes.ecTYPE_CONFLICT_FUN, -1, GetIdent(), argMax.GetValueType(), 'i', 1)); } if (argMax < argMin) { throw new ParserError("Colon operator: Maximum value smaller than Minimum!"); } long n = argMax.AsInteger() - argMin.AsInteger() + 1; var arr = new Matrix(n); for (long i = 0; i < n; ++i) { arr.At(i) = argMin.AsFloat() + i; } ret = arr; }
public override long AsInteger() { return(m_pVal.AsInteger()); }