Beispiel #1
0
 public NumberValue BinaryGet(BinaryValue value, NumberValue index)
 {
     if (index.Value < 0 || index.Value > value.Value.Length)
     {
         throw ProgramError.Fatal("Binary", "get index out of range");
     }
     return(NumberValue.Create(value.Value[(int)index.Value]));
 }
Beispiel #2
0
 public DataRow MakeEntry(CatalogEntry entry)
 {
     return(DataRow.Create(Table.Heading, new TypedValue[] {
         TextValue.Create(entry.Name),
         TextValue.Create(entry.Kind.ToString()),
         TextValue.Create(entry.DataType.BaseType.Name),
         BinaryValue.Create(entry.ToBinary())
     }));
 }
Beispiel #3
0
        public BinaryValue BinarySet(BinaryValue value, NumberValue index, NumberValue newvalue)
        {
            if (index.Value < 0 || index.Value > value.Value.Length)
            {
                throw ProgramError.Fatal("Binary", "set index out of range");
            }
            var b = value.Value.Clone() as byte[];

            b[(int)index.Value] = (byte)newvalue.Value;
            return(BinaryValue.Create(b));
        }
Beispiel #4
0
        ///=================================================================
        ///
        /// binary operations
        ///

        public BinaryValue Binary(TypedValue value)
        {
            if (value.DataType == DataTypes.Text)
            {
                return(BinaryValue.Default); // TODO: convert text to binary
            }
            if (value.DataType == DataTypes.Number)
            {
                var size = (int)((NumberValue)value).Value;
                return(BinaryValue.Create(new byte[size]));
            }
            throw ProgramError.Fatal("Binary", "invalid arg type");
        }
Beispiel #5
0
 public NumberValue BinaryLength(BinaryValue arg1)
 {
     return(NumberValue.Create(arg1.Value.Length));
 }
Beispiel #6
0
 public void SetBinary(int colno, byte[] value)
 {
     _valueholder._values[colno] = BinaryValue.Create(value);
 }
Beispiel #7
0
 static BinaryValue()
 {
     Default = new BinaryValue {
         Value = new byte[0]
     };
 }