예제 #1
0
        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);
        }
예제 #2
0
 public TypeReference(Class Class, Assembly assembly)
 {
     Type      = TypeReferenceType.Class;
     Name      = Class.FullName;
     ClassType = Class;
     assembly?.RegisterType(this);
 }
예제 #3
0
 public TypeReference(BaseIntegerType intType, Assembly assembly)
 {
     Type        = TypeReferenceType.Integer;
     Name        = intType.Name;
     IntegerType = intType;
     assembly?.RegisterType(this);
 }
예제 #4
0
 public TypeReference(ArrayType arrayType, Assembly assembly)
 {
     Type      = TypeReferenceType.Array;
     Name      = arrayType.Name;
     ArrayType = arrayType;
     assembly?.RegisterType(this);
 }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
파일: Constant.cs 프로젝트: Coestaris/hasm
 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");
     }
 }
예제 #8
0
파일: Constant.cs 프로젝트: Coestaris/hasm
 internal Constant(Integer value)
 {
     Type     = TypeReferenceType.Integer;
     IntValue = value;
 }
예제 #9
0
파일: Constant.cs 프로젝트: Coestaris/hasm
 internal Constant(ulong value)
 {
     Type     = TypeReferenceType.Integer;
     IntValue = new Integer(value, BaseIntegerType.CommonType);
 }
예제 #10
0
파일: Constant.cs 프로젝트: Coestaris/hasm
 internal Constant(Array value)
 {
     ArrayValue = value;
     Type       = TypeReferenceType.Array;
 }
예제 #11
0
파일: Constant.cs 프로젝트: Coestaris/hasm
 internal Constant(BaseIntegerType type)
 {
     Type     = TypeReferenceType.Integer;
     IntValue = new Integer(0, type);
 }
예제 #12
0
 protected abstract void DoWriteTypeAndName(TypeReference typeReference, string name, TypeReferenceType typeReferenceType);
예제 #13
0
 protected override sealed void WriteTypeAndName(TypeReference typeReference, string name, TypeReferenceType typeReferenceType)
 {
     DoWriteTypeAndName(typeReference, name, typeReferenceType);
 }