Beispiel #1
0
        int EnterGenericProvider(IGenericParameterProvider provider, CilType owner, int parameterIndex)
        {
            int pos = 0;

            foreach (var genericElement in provider.GenericParameters)
            {
                var item = new GenericStackItem();
                item.Name = CilType.GenericParameterFullName(genericElement);

                ++pos;  // index always +1
                if (parameterIndex == -1)
                {
                    item.Index = -pos;
                    item.Type  = owner;
                }
                else
                {
                    item.Index = parameterIndex + pos;
                }

                items.Add(item);
            }

            return(pos);
        }
Beispiel #2
0
 void EnterGenericInstance(IGenericInstance instance, IGenericParameterProvider provider)
 {
     if (instance.HasGenericArguments)
     {
         foreach (var genericElement in provider.GenericParameters)
         {
             var item            = new GenericStackItem();
             var genericArgument = instance.GenericArguments[genericElement.Position];
             if (genericArgument is ArrayType genericArgumentAsArray)
             {
                 item.GenericInstance = genericArgumentAsArray.ElementType as GenericInstanceType;
             }
             else
             {
                 item.GenericInstance = genericArgument as GenericInstanceType;
             }
             item.GenericParent = instance;
             item.Name          = CilType.GenericParameterFullName(genericElement);
             item.Type          = CilType.From(genericArgument);
             items.Add(item);
         }
     }
 }