示例#1
0
 public static IType Resolve(Type type)
 {
     if (type == null)
     {
         return(null);
     }
     if (MirrorUtility.IsGenericType(type))
     {
         return(null);
     }
     if (type.HasElementType)
     {
         Type elementType = type.GetElementType();
         if (type.IsArray)
         {
             ArrayTypeSymbol  sym       = new ArrayTypeSymbol(type.GetArrayRank());
             ArrayBackpatcher recursive = new ArrayBackpatcher(sym, type);
             Backpatcher.Register(recursive);
             return(sym);
         }
         else if (type.IsByRef)
         {
             ReferenceTypeSymbol  sym       = new ReferenceTypeSymbol();
             ReferenceBackpatcher recursive = new ReferenceBackpatcher(sym, type);
             Backpatcher.Register(recursive);
             return(sym);
         }
         else if (type.IsPointer)
         {
             PointerTypeSymbol  sym       = new PointerTypeSymbol();
             PointerBackpatcher recursive = new PointerBackpatcher(sym, type);
             Backpatcher.Register(recursive);
             return(sym);
         }
         return(null);
     }
     else
     {
         IType result;
         if (cache.TryGetValue(type, out result))
         {
             return(result);
         }
         else
         {
             result = Search(type);
             cache.Add(type, result);
             return(result);
         }
     }
 }
示例#2
0
 public ReferenceBackpatcher(ReferenceTypeSymbol symbol, Type type)
     : base(type)
 {
     this.symbol = symbol;
 }