public DatSymbolReference() { Object = UndeclaredSymbol; Attribute = null; Index = -1; }
/// <summary> /// Loads DatSymbol from binary DAT formatted stream /// </summary> public static DatSymbol Load(DatBinaryReader reader) { var symbol = new DatSymbol(); // Read Name var hasName = Convert.ToBoolean(reader.ReadUInt32()); if (hasName) { symbol.Name = reader.ReadString(); } // Read ReturnType / ClassSize / ClassVarOffset / ArrayLength / Type / Flags var valueField = reader.ReadInt32(); var bitField = reader.ReadUInt32(); symbol.ArrayLength = bitField & 0xFFF; symbol.Type = (DatSymbolType)((bitField & 0xF000) >> 12); symbol.Flags = (DatSymbolFlag)((bitField & 0x3F0000) >> 16); if (symbol.Type == DatSymbolType.Func && symbol.Flags.HasFlag(DatSymbolFlag.Return)) { symbol.ReturnType = (DatSymbolType)valueField; } if (symbol.Type == DatSymbolType.Class) { symbol.ClassSize = valueField; } if (symbol.Flags.HasFlag(DatSymbolFlag.Classvar)) { symbol.ClassVarOffset = valueField; } symbol.Location = new DatSymbolLocation { FileNumber = reader.ReadInt32(), Line = reader.ReadInt32(), LinesCount = reader.ReadInt32(), Position = reader.ReadInt32(), PositionsCount = reader.ReadInt32(), }; switch (symbol.Type) { case DatSymbolType.Class: symbol.ClassOffset = reader.ReadInt32(); break; case DatSymbolType.Func: case DatSymbolType.Instance: case DatSymbolType.Prototype: symbol.FirstTokenAddress = reader.ReadInt32(); break; default: symbol.Content = GetContentIfExists(reader, symbol); break; } symbol.ParentIndex = reader.ReadInt32(); return(symbol); }