Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Add ByteCode.GetBoughs function
Browse files Browse the repository at this point in the history
  • Loading branch information
bgk- committed May 27, 2024
1 parent 69fe6a0 commit cf38c1f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Topiary/ByteCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,32 @@ public static SortedSet<string> GetExterns(BinaryReader reader)

return result;
}

public static string[] GetBoughs(BinaryReader reader)
{
var globalSymbolsCount = reader.ReadUInt64();
var indexSize = Marshal.SizeOf<uint>();

for (ulong i = 0; i < globalSymbolsCount; i++)
{
var nameLength = reader.ReadByte();
reader.ReadBytes(nameLength); // skip name
reader.ReadBytes(indexSize); // skip globals index
reader.ReadByte();
reader.ReadByte(); // mutable
}

var boughCount = reader.ReadUInt64();
var result = new string[boughCount];
for (ulong i = 0; i < boughCount; i++)
{
var nameLength = reader.ReadByte();
var name = Encoding.UTF8.GetString(reader.ReadBytes(nameLength));
reader.ReadBytes(indexSize); // skip index
result[i] = name;
}

return result;
}
}
}

0 comments on commit cf38c1f

Please sign in to comment.