public TypeReference(string fullName, Assembly assembly) { Name = fullName; var bit = BaseIntegerType.Types.Find(p => p.Name == fullName); if (bit != null) { Type = TypeReferenceType.Integer; IntegerType = bit; return; } else if (ArrayType.ArrayTypeRegex.IsMatch(fullName)) { Type = TypeReferenceType.Array; ArrayType = new ArrayType(fullName, assembly); } else if (fullName == StringType.StringTypeKeyword) { Type = TypeReferenceType.Array; ArrayType = new StringType(assembly); } else { Type = TypeReferenceType.Class; } assembly?.RegisterType(this); }
public TypeReference(Class Class, Assembly assembly) { Type = TypeReferenceType.Class; Name = Class.FullName; ClassType = Class; assembly?.RegisterType(this); }
public TypeReference(BaseIntegerType intType, Assembly assembly) { Type = TypeReferenceType.Integer; Name = intType.Name; IntegerType = intType; assembly?.RegisterType(this); }
public TypeReference(ArrayType arrayType, Assembly assembly) { Type = TypeReferenceType.Array; Name = arrayType.Name; ArrayType = arrayType; assembly?.RegisterType(this); }
private IExtractedEntity CreateGenericHandle(IGenericContext gc, Handle handle) { IExtractedEntity entity; switch (handle.Kind) { case HandleKind.MethodDefinition: entity = new DefinitionMethod(gc, (MethodDefinitionHandle)handle); break; case HandleKind.MemberReference: entity = Create(gc, (MemberReferenceHandle)handle); break; case HandleKind.MethodSpecification: entity = new MethodSpecificationMethod(gc, (MethodSpecificationHandle)handle); break; case HandleKind.FieldDefinition: entity = new DefinitionField(gc.Context, (FieldDefinitionHandle)handle); break; case HandleKind.TypeReference: var tr = new TypeReferenceType(this, (TypeReferenceHandle)handle); if (tr.TryGetPrimitiveType(out var pt)) { // Map special names like `System.Int32` to `int` return(pt); } entity = tr; break; case HandleKind.TypeSpecification: return(Entities.Type.DecodeType(gc, (TypeSpecificationHandle)handle)); case HandleKind.TypeDefinition: entity = new TypeDefinitionType(this, (TypeDefinitionHandle)handle); break; case HandleKind.StandaloneSignature: var signature = MdReader.GetStandaloneSignature((StandaloneSignatureHandle)handle); var method = signature.DecodeMethodSignature(gc.Context.TypeSignatureDecoder, gc); entity = new FunctionPointerType(this, method); break; default: throw new InternalError("Unhandled handle kind " + handle.Kind); } Populate(entity); return(entity); }
IExtractedEntity CreateGenericHandle(GenericContext gc, Handle handle) { IExtractedEntity entity; switch (handle.Kind) { case HandleKind.MethodDefinition: entity = new DefinitionMethod(gc, (MethodDefinitionHandle)handle); break; case HandleKind.MemberReference: entity = Create(gc, (MemberReferenceHandle)handle); break; case HandleKind.MethodSpecification: entity = new MethodSpecificationMethod(gc, (MethodSpecificationHandle)handle); break; case HandleKind.FieldDefinition: entity = new DefinitionField(gc, (FieldDefinitionHandle)handle); break; case HandleKind.TypeReference: var tr = new TypeReferenceType(this, (TypeReferenceHandle)handle); if (tr.TryGetPrimitiveType(out var pt)) { // Map special names like `System.Int32` to `int` return(pt); } entity = tr; break; case HandleKind.TypeSpecification: return(Entities.Type.DecodeType(gc, (TypeSpecificationHandle)handle)); case HandleKind.TypeDefinition: entity = new TypeDefinitionType(this, (TypeDefinitionHandle)handle); break; default: throw new InternalError("Unhandled handle kind " + handle.Kind); } Populate(entity); return(entity); }
internal Constant(Variable variable) { if (variable.Value.Type.Type == TypeReferenceType.Array) { Type = TypeReferenceType.Array; ArrayValue = variable.Value.ArrayValue; } else if (variable.Value.Type.Type == TypeReferenceType.Integer) { Type = TypeReferenceType.Integer; IntValue = variable.Value.IntegerValue; } else { throw new System.ArgumentException("Wrong type given"); } }
internal Constant(Integer value) { Type = TypeReferenceType.Integer; IntValue = value; }
internal Constant(ulong value) { Type = TypeReferenceType.Integer; IntValue = new Integer(value, BaseIntegerType.CommonType); }
internal Constant(Array value) { ArrayValue = value; Type = TypeReferenceType.Array; }
internal Constant(BaseIntegerType type) { Type = TypeReferenceType.Integer; IntValue = new Integer(0, type); }
protected abstract void DoWriteTypeAndName(TypeReference typeReference, string name, TypeReferenceType typeReferenceType);
protected override sealed void WriteTypeAndName(TypeReference typeReference, string name, TypeReferenceType typeReferenceType) { DoWriteTypeAndName(typeReference, name, typeReferenceType); }