Example #1
0
        public ITypeParameter Register(GenericParameter parameter, IEntity owner, int index)
        {
            if (store.TryGetValue(parameter.Id, out var existingP))
            {
                if (!existingP.Owner.Equals(owner))
                {
                    throw new Exception($"There is collision in the usage of generic parameter {parameter}: both {existingP.Owner} and {owner} use it.");
                }
                if (existingP.Index != index)
                {
                    throw new Exception($"There is collision in the usage of generic parameter {parameter} on {existingP.Owner}. It is used at index {existingP.Index} and {index}.");
                }
                return(existingP);
            }

            var newP = new DefaultTypeParameter(owner, index, name: NameSanitizer.SanitizeCsharpName(parameter.Name, lowerCase: null));

            SymbolLoader.RegisterTypeParameter(newP, parameter);
            store.TryAdd(parameter.Id, newP);
            return(Register(parameter, owner, index));
        }
Example #2
0
 /// <summary> Adds a new entity into <see cref="DeclaredEntities" />. </summary>
 internal void RegisterEntity(MemberDef member, IEntity entity)
 {
     declaredEntities.Add(member.Signature, entity);
     SymbolLoader.RegisterDeclaredEntity(entity, member.Signature);
 }