public static BitsConst Multiply(BitsConst left, int right) => left * Convert(right);
public BitsArrayValue(BitsConst data) { _data = data; }
public BitsConst Slash(BitsConst right, Size size) => Divide(right, size);
public BitsStackData(BitsConst data, IOutStream outStream) : base(outStream) { _data = data; Tracer.Assert(!_data.Size.IsZero); }
static BitsConst Paste(BitsConst bitsConst, NonListStackData data) => bitsConst.Concat(data.GetBitsConst());
public static BitsConst Divide(BitsConst left, int right) => left / Convert(right);
internal BitsConst BitArrayBinaryOp(string operation, Size size, BitsConst right) { var methodInfo = typeof(BitsConst).GetMethod(operation); if(methodInfo == null) throw new MissingMethodException(operation); return (BitsConst) methodInfo.Invoke(this, new object[] {right, size}); }
public BitsConst LessEqual(BitsConst right, Size size) => ToBitsConst(AsInteger <= right.AsInteger, size);
public BitsConst LessGreater(BitsConst right, Size size) => ToBitsConst(AsInteger != right.AsInteger, size);
public BitsConst Minus(BitsConst right, Size size) => Plus(right * -1, size);
public BitsConst GreaterEqual(BitsConst right, Size size) => ToBitsConst(AsInteger >= right.AsInteger, size);
public BitsConst Plus(BitsConst right, Size size) { var xResult = new BitsConst(this, size); var yResult = new BitsConst(right, size); xResult.AddAndKeepSize(yResult); return xResult; }
public BitsConst BytePlus(BitsConst left, int bytes) => Plus(left, SegmentBits * bytes);
public BitsConst Divide(BitsConst right, Size size) { if(!(Marshal.SizeOf(typeof(long)) * 8 >= size.ToInt())) Tracer.AssertionFailed ( @"sizeof(Int64)*8 >= size.ToInt()", () => "right=" + right + ";size=" + size.Dump()); return Convert(ToInt64() / right.ToInt64()).Resize(size); }
BitsConst(BitsConst value, Size size) : this(size) { MoveData(_data, Size, value._data, value.Size); }
public BitsConst Concat(BitsConst other) { Size.AssertAlignedSize(SegmentAlignBits); var result = new BitsConst(Size + other.Size); DataHandler.MoveBytes(DataSize(Size), result._data, 0, _data, 0); DataHandler.MoveBytes (DataSize(other.Size), result._data, DataSize(Size), other._data, 0); return result; }
public static BitsConst Divide(BitsConst left, BitsConst right) => left.Divide(right, DivideSize(left.Size, right.Size));
public void PrintNumber(BitsConst radix, IOutStream outStream) { var r = radix.ToInt64(); if(radix.Size.IsZero) r = 10; var left = ToString((int) r); outStream.AddData(left); }
void AddAndKeepSize(BitsConst left) { short carry = 0; for(var i = 0; i < _data.Length; i++) { carry += _data[i]; carry += left._data[i]; _data[i] = (byte) carry; carry /= (short) SegmentValues; } return; }
public static BitsConst Add(BitsConst left, BitsConst right) => left.Plus(right, PlusSize(left.Size, right.Size));
void IVisitor.BitsArray(Size size, BitsConst data) { if(size.IsZero) return; Push(new BitsStackData(data.Resize(size), _context.OutStream)); }
public static BitsConst Subtract(BitsConst left, BitsConst right) => left.Plus(right * -1, PlusSize(left.Size, right.Size));
void IVisitor.BitsArray(Size size, BitsConst data) => AddCode("data.SizedPush({0}{1})", size.ByteCount, data.ByteSequence());
public static BitsConst Subtract(int left, BitsConst right) => Convert(left) - right;
void IVisitor.BitsArray(Size size, BitsConst data) { var startAddress = (_startAddress - size).ToInt(); var element = FormalValueAccess.BitsArray(data); SetFormalValues(element, startAddress, size); }
public static BitsConst Multiply(BitsConst left, BitsConst right) => left.Multiply(right, MultiplySize(left.Size, right.Size));
public static IFormalValue BitsArray(BitsConst data) => new BitsArrayValue(data);
public BitsConst Star(BitsConst right, Size size) => Multiply(right, size);