void addSentinelType(SentinelType st) { if (st == null) { return; } addTypeSpecification(st); }
void doSentinelType(SentinelType sentinelType) { if (sentinelTypes.ContainsKey(sentinelType)) { return; } sentinelTypes[sentinelType] = true; addSentinelType(sentinelType); }
public TypeReference Visit(SentinelType current, IGenericContext gcontext) { var result = new SentinelType(Get(current.ElementType, gcontext)); if (current.HasGenericParameters) { CopyAndUpdate(result, current, gcontext); } return(result); }
internal Type ResolveTypeSpecification(TypeSpecification typeSpecification) { Type elementType = ResolveType(typeSpecification.ElementType); ArrayType arrayType = typeSpecification as ArrayType; if (arrayType != null) { if (arrayType.IsSizedArray) { return(elementType.MakeArrayType()); } return(elementType.MakeArrayType(arrayType.Rank)); } GenericInstanceType genericInstanceType = typeSpecification as GenericInstanceType; if (genericInstanceType != null) { Type[] args = ResolveTypes(genericInstanceType.GenericArguments); return(elementType.MakeGenericType(args)); } ReferenceType referenceType = typeSpecification as ReferenceType; if (referenceType != null) { return(elementType.MakeByRefType()); } PointerType pointerType = typeSpecification as PointerType; if (pointerType != null) { return(elementType.MakePointerType()); } FunctionPointerType functionPointerType = typeSpecification as FunctionPointerType; PinnedType pinnedType = typeSpecification as PinnedType; ModifierOptional modifierOptional = typeSpecification as ModifierOptional; ModifierRequired modifierRequired = typeSpecification as ModifierRequired; SentinelType sentinelType = typeSpecification as SentinelType; throw new NotImplementedException(); }
protected void VisitTypeReference(TypeReference typeReference, Context context) { GenericParameter genericParameter = typeReference as GenericParameter; if (genericParameter != null) { this.Visit(genericParameter, context); } else { ArrayType arrayType = typeReference as ArrayType; if (arrayType != null) { this.Visit(arrayType, context); } else { PointerType pointerType = typeReference as PointerType; if (pointerType != null) { this.Visit(pointerType, context); } else { ByReferenceType byReferenceType = typeReference as ByReferenceType; if (byReferenceType != null) { this.Visit(byReferenceType, context); } else { FunctionPointerType functionPointerType = typeReference as FunctionPointerType; if (functionPointerType != null) { this.Visit(functionPointerType, context); } else { PinnedType pinnedType = typeReference as PinnedType; if (pinnedType != null) { this.Visit(pinnedType, context); } else { SentinelType sentinelType = typeReference as SentinelType; if (sentinelType != null) { this.Visit(sentinelType, context); } else { GenericInstanceType genericInstanceType = typeReference as GenericInstanceType; if (genericInstanceType != null) { this.Visit(genericInstanceType, context); } else { RequiredModifierType requiredModifierType = typeReference as RequiredModifierType; if (requiredModifierType != null) { this.Visit(requiredModifierType, context); } else { this.Visit(typeReference, context); } } } } } } } } } }
protected virtual void Visit(SentinelType sentinelType, Context context) { this.VisitTypeReference(sentinelType.ElementType, context.ElementType(sentinelType)); }
public NetTypeReference Visit(SentinelType type, ResolveData data) { throw new NotImplementedException("SentinelType to NetTypeReference"); }
private static TypeReference ImportType(TypeReference typeRef, ModuleDefinition mod, MethodReference context, Dictionary <MetadataToken, IMemberDefinition> mems) { TypeReference ret = typeRef; if (typeRef is TypeSpecification) { if (typeRef is ArrayType) { ArrayType _spec = typeRef as ArrayType; ret = new ArrayType(ImportType(_spec.ElementType, mod, context, mems)); (ret as ArrayType).Dimensions.Clear(); foreach (var i in _spec.Dimensions) { (ret as ArrayType).Dimensions.Add(i); } } else if (typeRef is GenericInstanceType) { GenericInstanceType _spec = typeRef as GenericInstanceType; ret = new GenericInstanceType(ImportType(_spec.ElementType, mod, context, mems)); foreach (var i in _spec.GenericArguments) { (ret as GenericInstanceType).GenericArguments.Add(ImportType(i, mod, context, mems)); } } else if (typeRef is OptionalModifierType) { ret = new OptionalModifierType( ImportType((typeRef as OptionalModifierType).ModifierType, mod, context, mems), ImportType((typeRef as TypeSpecification).ElementType, mod, context, mems)); } else if (typeRef is RequiredModifierType) { ret = new RequiredModifierType( ImportType((typeRef as RequiredModifierType).ModifierType, mod, context, mems), ImportType((typeRef as TypeSpecification).ElementType, mod, context, mems)); } else if (typeRef is ByReferenceType) { ret = new ByReferenceType(ImportType((typeRef as TypeSpecification).ElementType, mod, context, mems)); } else if (typeRef is PointerType) { ret = new PointerType(ImportType((typeRef as TypeSpecification).ElementType, mod, context, mems)); } else if (typeRef is PinnedType) { ret = new PinnedType(ImportType((typeRef as TypeSpecification).ElementType, mod, context, mems)); } else if (typeRef is SentinelType) { ret = new SentinelType(ImportType((typeRef as TypeSpecification).ElementType, mod, context, mems)); } else { throw new NotSupportedException(); } } else if (typeRef is GenericParameter) { if (context == null || (typeRef as GenericParameter).Owner is TypeReference || (typeRef as GenericParameter).Position >= context.GenericParameters.Count) { return(typeRef); } return(context.GenericParameters[(typeRef as GenericParameter).Position]); } else { if (mems != null && mems.ContainsKey(typeRef.MetadataToken)) { ret = mems[typeRef.MetadataToken] as TypeReference; } else if (!(ret is TypeDefinition) && typeRef.Scope.Name != "Confuser.Core.Injections.dll") { ret = mod.Import(ret); } } return(ret); }
protected override void Visit(SentinelType sentinelType, Context context) { Touch(sentinelType); base.Visit(sentinelType, context); }
public CodeTypeReference Visit(SentinelType type, object data) { throw new System.NotImplementedException(); }
public TypeReference Resolve(TypeReference typeReference) { GenericParameter genericParameter = typeReference as GenericParameter; if (genericParameter != null) { return(this.Resolve(this.ResolveGenericParameter(genericParameter))); } ArrayType arrayType = typeReference as ArrayType; if (arrayType != null) { return(new ArrayType(this.Resolve(arrayType.ElementType), arrayType.Rank)); } PointerType pointerType = typeReference as PointerType; if (pointerType != null) { return(new PointerType(this.Resolve(pointerType.ElementType))); } ByReferenceType byReferenceType = typeReference as ByReferenceType; if (byReferenceType != null) { return(new ByReferenceType(this.Resolve(byReferenceType.ElementType))); } GenericInstanceType genericInstanceType = typeReference as GenericInstanceType; if (genericInstanceType != null) { GenericInstanceType genericInstanceType2 = new GenericInstanceType(this.Resolve(genericInstanceType.ElementType)); foreach (TypeReference current in genericInstanceType.GenericArguments) { genericInstanceType2.GenericArguments.Add(this.Resolve(current)); } return(genericInstanceType2); } PinnedType pinnedType = typeReference as PinnedType; if (pinnedType != null) { return(new PinnedType(this.Resolve(pinnedType.ElementType))); } RequiredModifierType requiredModifierType = typeReference as RequiredModifierType; if (requiredModifierType != null) { return(this.Resolve(requiredModifierType.ElementType)); } OptionalModifierType optionalModifierType = typeReference as OptionalModifierType; if (optionalModifierType != null) { return(new OptionalModifierType(this.Resolve(optionalModifierType.ModifierType), this.Resolve(optionalModifierType.ElementType))); } SentinelType sentinelType = typeReference as SentinelType; if (sentinelType != null) { return(new SentinelType(this.Resolve(sentinelType.ElementType))); } FunctionPointerType functionPointerType = typeReference as FunctionPointerType; if (functionPointerType != null) { throw new NotSupportedException("Function pointer types are not supported by the SerializationWeaver"); } if (typeReference is TypeSpecification) { throw new NotSupportedException(); } return(typeReference); }
static bool compareSentinelTypes(Type a, SentinelType b) { return compareTypes(a, b.ElementType); }
protected virtual SentinelType updateSentinelType(SentinelType a) { return(new SentinelType(update(a.ElementType))); }
private static TypeReference InflateGenericType(GenericInstanceType genericInstanceProvider, TypeReference typeToInflate) { ArrayType type = typeToInflate as ArrayType; if (type != null) { TypeReference reference = InflateGenericType(genericInstanceProvider, type.ElementType); if (reference != type.ElementType) { return(new ArrayType(reference, type.Rank)); } return(type); } GenericInstanceType baseType = typeToInflate as GenericInstanceType; if (baseType != null) { return(MakeGenericType(genericInstanceProvider, baseType)); } GenericParameter genericParameter = typeToInflate as GenericParameter; if (genericParameter != null) { GenericParameter parameter = ResolveType(genericInstanceProvider.ElementType).GenericParameters.Single <GenericParameter>(p => p == genericParameter); return(genericInstanceProvider.GenericArguments[parameter.Position]); } FunctionPointerType type3 = typeToInflate as FunctionPointerType; if (type3 != null) { FunctionPointerType type9 = new FunctionPointerType { ReturnType = InflateGenericType(genericInstanceProvider, type3.ReturnType) }; for (int i = 0; i < type3.Parameters.Count; i++) { TypeReference parameterType = InflateGenericType(genericInstanceProvider, type3.Parameters[i].ParameterType); type9.Parameters.Add(new ParameterDefinition(parameterType)); } return(type9); } IModifierType type4 = typeToInflate as IModifierType; if (type4 != null) { TypeReference modifierType = InflateGenericType(genericInstanceProvider, type4.ModifierType); TypeReference reference4 = InflateGenericType(genericInstanceProvider, type4.ElementType); if (type4 is OptionalModifierType) { return(new OptionalModifierType(modifierType, reference4)); } return(new RequiredModifierType(modifierType, reference4)); } PinnedType type5 = typeToInflate as PinnedType; if (type5 != null) { TypeReference reference5 = InflateGenericType(genericInstanceProvider, type5.ElementType); if (reference5 != type5.ElementType) { return(new PinnedType(reference5)); } return(type5); } PointerType type6 = typeToInflate as PointerType; if (type6 != null) { TypeReference reference6 = InflateGenericType(genericInstanceProvider, type6.ElementType); if (reference6 != type6.ElementType) { return(new PointerType(reference6)); } return(type6); } ByReferenceType type7 = typeToInflate as ByReferenceType; if (type7 != null) { TypeReference reference7 = InflateGenericType(genericInstanceProvider, type7.ElementType); if (reference7 != type7.ElementType) { return(new ByReferenceType(reference7)); } return(type7); } SentinelType type8 = typeToInflate as SentinelType; if (type8 == null) { return(typeToInflate); } TypeReference reference8 = InflateGenericType(genericInstanceProvider, type8.ElementType); if (reference8 != type8.ElementType) { return(new SentinelType(reference8)); } return(type8); }
public static int GetHashCodeFor(TypeReference obj) { MetadataType metadataType = obj.MetadataType; switch (metadataType) { case MetadataType.GenericInstance: { GenericInstanceType type2 = (GenericInstanceType)obj; int num = (GetHashCodeFor(type2.ElementType) * 0x1cfaa2db) + 0x1f; for (int i = 0; i < type2.GenericArguments.Count; i++) { num = (num * 0x1cfaa2db) + GetHashCodeFor(type2.GenericArguments[i]); } return(num); } case MetadataType.Array: { ArrayType type3 = (ArrayType)obj; return((GetHashCodeFor(type3.ElementType) * 0x1cfaa2db) + type3.Rank.GetHashCode()); } case MetadataType.Var: case MetadataType.MVar: { GenericParameter parameter = (GenericParameter)obj; int num7 = (int)metadataType; int num5 = (parameter.Position.GetHashCode() * 0x1cfaa2db) + num7.GetHashCode(); TypeReference owner = parameter.Owner as TypeReference; if (owner != null) { return((num5 * 0x1cfaa2db) + GetHashCodeFor(owner)); } MethodReference reference2 = parameter.Owner as MethodReference; if (reference2 == null) { throw new InvalidOperationException("Generic parameter encountered with invalid owner"); } return((num5 * 0x1cfaa2db) + Unity.IL2CPP.Common.MethodReferenceComparer.GetHashCodeFor(reference2)); } case MetadataType.ByReference: { ByReferenceType type4 = (ByReferenceType)obj; return((GetHashCodeFor(type4.ElementType) * 0x1cfaa2db) * 0x25); } case MetadataType.Pointer: { PointerType type5 = (PointerType)obj; return((GetHashCodeFor(type5.ElementType) * 0x1cfaa2db) * 0x29); } case MetadataType.RequiredModifier: { RequiredModifierType type6 = (RequiredModifierType)obj; int num8 = GetHashCodeFor(type6.ElementType) * 0x2b; return((num8 * 0x1cfaa2db) + GetHashCodeFor(type6.ModifierType)); } case MetadataType.OptionalModifier: { OptionalModifierType type7 = (OptionalModifierType)obj; int num9 = GetHashCodeFor(type7.ElementType) * 0x2f; return((num9 * 0x1cfaa2db) + GetHashCodeFor(type7.ModifierType)); } case MetadataType.Pinned: { PinnedType type8 = (PinnedType)obj; return((GetHashCodeFor(type8.ElementType) * 0x1cfaa2db) * 0x35); } case MetadataType.Sentinel: { SentinelType type9 = (SentinelType)obj; return((GetHashCodeFor(type9.ElementType) * 0x1cfaa2db) * 0x3b); } case MetadataType.FunctionPointer: throw new NotImplementedException("We currently don't handle function pointer types."); } return((obj.Namespace.GetHashCode() * 0x1cfaa2db) + obj.FullName.GetHashCode()); }
public TypeReference Resolve(TypeReference typeReference) { GenericParameter genericParameter = typeReference as GenericParameter; if (genericParameter != null) { return(this.Resolve(this.ResolveGenericParameter(genericParameter))); } ArrayType type = typeReference as ArrayType; if (type != null) { return(new ArrayType(this.Resolve(type.ElementType), type.Rank)); } PointerType type2 = typeReference as PointerType; if (type2 != null) { return(new PointerType(this.Resolve(type2.ElementType))); } ByReferenceType type3 = typeReference as ByReferenceType; if (type3 != null) { return(new ByReferenceType(this.Resolve(type3.ElementType))); } GenericInstanceType type4 = typeReference as GenericInstanceType; if (type4 != null) { GenericInstanceType type5 = new GenericInstanceType(this.Resolve(type4.ElementType)); foreach (TypeReference reference2 in type4.GenericArguments) { type5.GenericArguments.Add(this.Resolve(reference2)); } return(type5); } PinnedType type6 = typeReference as PinnedType; if (type6 != null) { return(new PinnedType(this.Resolve(type6.ElementType))); } RequiredModifierType type7 = typeReference as RequiredModifierType; if (type7 != null) { return(this.Resolve(type7.ElementType)); } OptionalModifierType type8 = typeReference as OptionalModifierType; if (type8 != null) { return(new OptionalModifierType(this.Resolve(type8.ModifierType), this.Resolve(type8.ElementType))); } SentinelType type9 = typeReference as SentinelType; if (type9 != null) { return(new SentinelType(this.Resolve(type9.ElementType))); } if (typeReference is FunctionPointerType) { throw new NotSupportedException("Function pointer types are not supported by the SerializationWeaver"); } if (typeReference is TypeSpecification) { throw new NotSupportedException(); } return(typeReference); }