private void EnsureInitialized() { if (_boundsList != null) { return; } ReadyToRunReader _readyToRunReader = _runtimeFunction.ReadyToRunReader; int offset = _offset; _boundsList = new List <DebugInfoBoundsEntry>(); _variablesList = new List <NativeVarInfo>(); Machine machine = _readyToRunReader.Machine; byte[] image = _readyToRunReader.Image; _machine = machine; // Get the id of the runtime function from the NativeArray uint lookback = 0; uint debugInfoOffset = NativeReader.DecodeUnsigned(image, (uint)offset, ref lookback); if (lookback != 0) { System.Diagnostics.Debug.Assert(0 < lookback && lookback < offset); debugInfoOffset = (uint)offset - lookback; } NibbleReader reader = new NibbleReader(image, (int)debugInfoOffset); uint boundsByteCount = reader.ReadUInt(); uint variablesByteCount = reader.ReadUInt(); int boundsOffset = reader.GetNextByteOffset(); int variablesOffset = (int)(boundsOffset + boundsByteCount); if (boundsByteCount > 0) { ParseBounds(image, boundsOffset); } if (variablesByteCount > 0) { ParseNativeVarInfo(image, variablesOffset); } }
public bool TryGetAt(byte[] image, uint index, ref int pOffset) { if (index >= _nElements) { return(false); } uint offset = 0; if (_entryIndexSize == 0) { int i = (int)(_baseOffset + (index / _blockSize)); offset = NativeReader.ReadByte(image, ref i); } else if (_entryIndexSize == 1) { int i = (int)(_baseOffset + 2 * (index / _blockSize)); offset = NativeReader.ReadUInt16(image, ref i); } else { int i = (int)(_baseOffset + 4 * (index / _blockSize)); offset = NativeReader.ReadUInt32(image, ref i); } offset += _baseOffset; for (uint bit = _blockSize >> 1; bit > 0; bit >>= 1) { uint val = 0; uint offset2 = NativeReader.DecodeUnsigned(image, offset, ref val); if ((index & bit) != 0) { if ((val & 2) != 0) { offset = offset + (val >> 2); continue; } } else { if ((val & 1) != 0) { offset = offset2; continue; } } // Not found if ((val & 3) == 0) { // Matching special leaf node? if ((val >> 2) == (index & (_blockSize - 1))) { offset = offset2; break; } } return(false); } pOffset = (int)offset; return(true); }