// https://github.com/dart-lang/sdk/blob/master/pkg/kernel/lib/binary/ast_from_binary.dart#L760 public Library(ComponentReader reader) { // Read the Offsets and Counts in a backward fashion var p = reader.Length - sizeof(uint); reader.Position = p; procedureCount = reader.ReadUint32(); p -= sizeof(uint) * ((int)procedureCount + 1); reader.Position = p; procedureOffsets = reader.ReadUint32s((int)procedureCount + 1); p -= sizeof(uint); reader.Position = p; classCount = reader.ReadUint32(); p -= sizeof(uint) * ((int)classCount + 1); reader.Position = p; classOffsets = reader.ReadUint32s((int)classCount + 1); reader.Position = 0; flags = reader.ReadByte(); canonicalName = new CanonicalNameReference(reader); name = new StringReference(reader); // todo: remove! Console.WriteLine($"{reader.GetString(name)} :: {classOffsets.Length} :: {classCount} || {procedureOffsets.Length} :: {procedureCount};"); fileUri = new UriReference(reader); // List<String> problemsAsJson; // Described in problems.md. annotations = reader.ReadList(r => r.ReadExpression()); libraryDependencies = reader.ReadList(r => new LibraryDependency(r)); additionalExports = reader.ReadList(r => new CanonicalNameReference(r)); libraryParts = reader.ReadList(r => new LibraryPart(r)); typedefs = reader.ReadList(r => new Typedef(r)); // https://github.com/dart-lang/sdk/blob/master/pkg/kernel/lib/binary/ast_from_binary.dart#L831 // classes = reader.ReadList(r => new Class(r)); classes = new List <Class>((int)classCount); for (int i = 0; i < classCount; i++) { var start = classOffsets[i]; var end = classOffsets[i + 1]; classes.Add(new Class(reader.GetWindow(start, end - start))); } reader.Position = (int)classOffsets.Last() - reader.WindowOffset; fields = reader.ReadList(r => new Field(r)); // procedures = reader.ReadList(r => new Procedure(r)); procedures = new List <Procedure>((int)procedureCount); for (int i = 0; i < procedureCount; i++) { var start = procedureOffsets[i]; var end = procedureOffsets[i + 1]; procedures.Add(new Procedure(reader.GetWindow(start, end - start))); } }
public UriSource(ComponentReader reader) { length = reader.ReadUint32(); source = new SourceInfo[length]; sourceIndex = new uint[length]; for (int i = 0; i < length; i++) { source[i] = new SourceInfo(reader); } for (int i = 0; i < length; i++) { sourceIndex[i] = reader.ReadUint32(); } }