예제 #1
0
        /// <summary>
        /// Constructor that will maintain an objects property in zmemory
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="propAddress"></param>
        /// <param name="header"></param>
        public ZProperty(IMemoryManager manager, ushort propAddress, ZHeader header)
        {
            _manager        = manager;
            _header         = header;
            PropertyAddress = propAddress;
            var ptr      = propAddress;
            var propByte = _manager.Get(PropertyAddress);

            if (_header.Version > 3 && (byte)(propByte & Bits.Bit7) == Bits.Bit7)
            {
                Number = GetPropertyNumber(propByte);
                Length = (ushort)(_manager.Get(++ptr) & 0x3F);

                if (Length == 0)
                {
                    Length = 64;
                }
            }
            else
            {
                Number = GetPropertyNumber(propByte);
                Length = GetPropertySize(propByte);
            }

            DataAddress = (ushort)(PropertyAddress + 1);
            _data       = _manager.AsSpan(DataAddress, 2);
            BytesUsed   = (ushort)(Length + 1);
        }
예제 #2
0
        public List <ushort> GetOperands(byte opcode)
        {
            var args = new List <ushort>();

            if (Bits.BitsSet(opcode, (byte)OperationForm.Variable))
            {
                // Section 4.4.3
                var  types  = _memoryManager.Get(_stack.GetPCAndInc());
                byte types2 = 0;

                if (opcode == 0xec || opcode == 0xfa)
                {
                    types2 = _memoryManager.Get(_stack.GetPCAndInc());
                }

                GetVariableOperands(types, args);
                if (opcode == 0xec || opcode == 0xfa)
                {
                    GetVariableOperands(types2, args);
                }
            }
            else if (Bits.BitsSet(opcode, (byte)OperationForm.Short))
            {
                // Section 4.4.1
                args.Add(GetOperand(ShortFormOperandType(opcode)));
            }
            else // Long Form
            {
                // Section 4.4.2
                args.Add(GetOperand(LongFormOperandType1(opcode)));
                args.Add(GetOperand(LongFormOperandType2(opcode)));
            }

            return(args);
        }
예제 #3
0
        /// <summary>
        /// Fetches value by its reference.
        /// </summary>
        /// <param name="reference">Reference to the value</param>
        /// <returns>The instance of value</returns>
        public TValue Fetch(DbItemReference reference)
        {
            var item = _memoryManager.Get(reference);

            if (IsVersioningEnabled)
            {
                var record = new VersionedRecord(item.RawData, _memoryManager, SnapshotData);

                if (record.HasVisibleVersionTo(DataTankerTransaction.Current.Id))
                {
                    item = record.GetMatchingVersion(DataTankerTransaction.Current.Id);
                }
            }

            return(_valueSerializer.Deserialize(item.RawData));
        }
예제 #4
0
 public DbItem GetMatchingVersion(int transactionNumber)
 {
     return(_versions
            .Where(version => IsVersionVisibleTo(version, transactionNumber))
            .Select(version => _memoryManager.Get(version.VersionReference))
            .FirstOrDefault());
 }