private static SyntaxTreeIndex?ReadIndex(
            StringTable stringTable, ObjectReader reader, Checksum?checksum)
        {
            var literalInfo    = LiteralInfo.TryReadFrom(reader);
            var identifierInfo = IdentifierInfo.TryReadFrom(reader);
            var contextInfo    = ContextInfo.TryReadFrom(reader);

            if (literalInfo == null || identifierInfo == null || contextInfo == null)
            {
                return(null);
            }

            var globalAliasInfoCount = reader.ReadInt32();
            HashSet <(string alias, string name, int arity)>?globalAliasInfo = null;

            if (globalAliasInfoCount > 0)
            {
                globalAliasInfo = new HashSet <(string alias, string name, int arity)>();

                for (var i = 0; i < globalAliasInfoCount; i++)
                {
                    var alias = reader.ReadString();
                    var name  = reader.ReadString();
                    var arity = reader.ReadInt32();
                    globalAliasInfo.Add((alias, name, arity));
                }
            }

            return(new SyntaxTreeIndex(
                       checksum,
                       literalInfo.Value,
                       identifierInfo.Value,
                       contextInfo.Value,
                       globalAliasInfo));
        }
예제 #2
0
        private static SyntaxTreeIndex?ReadFrom(
            StringTable stringTable,
            ObjectReader reader,
            Checksum?checksum
            )
        {
            var literalInfo         = LiteralInfo.TryReadFrom(reader);
            var identifierInfo      = IdentifierInfo.TryReadFrom(reader);
            var contextInfo         = ContextInfo.TryReadFrom(reader);
            var declarationInfo     = DeclarationInfo.TryReadFrom(stringTable, reader);
            var extensionMethodInfo = ExtensionMethodInfo.TryReadFrom(reader);

            if (
                literalInfo == null ||
                identifierInfo == null ||
                contextInfo == null ||
                declarationInfo == null ||
                extensionMethodInfo == null
                )
            {
                return(null);
            }

            return(new SyntaxTreeIndex(
                       checksum,
                       literalInfo.Value,
                       identifierInfo.Value,
                       contextInfo.Value,
                       declarationInfo.Value,
                       extensionMethodInfo.Value
                       ));
        }
        private static SyntaxTreeIndex ReadFrom(ObjectReader reader, VersionStamp version)
        {
            var literalInfo     = LiteralInfo.TryReadFrom(reader);
            var identifierInfo  = IdentifierInfo.TryReadFrom(reader);
            var contextInfo     = ContextInfo.TryReadFrom(reader);
            var declarationInfo = DeclarationInfo.TryReadFrom(reader);

            if (literalInfo == null || identifierInfo == null || contextInfo == null || declarationInfo == null)
            {
                return(null);
            }

            return(new SyntaxTreeIndex(
                       version, literalInfo.Value, identifierInfo.Value, contextInfo.Value, declarationInfo.Value));
        }