当前位置: 首页>>代码示例>>C#>>正文


C# IType.ToClass方法代码示例

本文整理汇总了C#中IType.ToClass方法的典型用法代码示例。如果您正苦于以下问题:C# IType.ToClass方法的具体用法?C# IType.ToClass怎么用?C# IType.ToClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IType的用法示例。


在下文中一共展示了IType.ToClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SynthesizedNewMethod

 /// <summary>
 /// </summary>
 /// <param name="type">
 /// </param>
 /// <param name="writer">
 /// </param>
 public SynthesizedNewMethod(IType type, LlvmWriter writer)
     : base(type, ".new")
 {
     this.writer = writer;
     this.Type = type.ToClass();
 }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:12,代码来源:SynthesizedNewMethod.cs

示例2: WriteUnboxObject

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="declaringType">
        /// </param>
        /// <returns>
        /// </returns>
        public static bool WriteUnboxObject(this LlvmWriter llvmWriter, OpCodePart opCode, IType declaringType)
        {
            var writer = llvmWriter.Output;

            var isStruct = declaringType.IsStructureType();

            writer.WriteLine("; Unboxing");
            writer.WriteLine(string.Empty);

            llvmWriter.CheckIfExternalDeclarationIsRequired(declaringType);

            writer.WriteLine("; Copy data");

            if (!isStruct)
            {
                // write access to a field
                if (!llvmWriter.WriteFieldAccess(
                        writer, 
                        opCode, 
                        declaringType.ToClass(), 
                        declaringType.ToClass(), 
                        0, 
                        opCode.Result))
                {
                    writer.WriteLine("; No data");
                    return false;
                }

                writer.WriteLine(string.Empty);
            }

            // load value from field
            var memberAccessResultNumber = opCode.Result;

            if (!isStruct)
            {
                opCode.Result = null;
            }

            llvmWriter.WriteLlvmLoad(opCode, memberAccessResultNumber.Type.ToNormal(), memberAccessResultNumber);

            writer.WriteLine(string.Empty);
            writer.WriteLine("; End of Copy data");

            return true;
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:56,代码来源:ObjectInfrastructure.cs

示例3: SynthesizedNewMethod

 /// <summary>
 /// </summary>
 /// <param name="type">
 /// </param>
 /// <param name="writer">
 /// </param>
 public SynthesizedNewMethod(IType type, ITypeResolver typeResolver)
     : base(type, ".new")
 {
     Type = type.ToClass();
     this.typeResolver = typeResolver;
 }
开发者ID:afrog33k,项目名称:csnative,代码行数:12,代码来源:SynthesizedNewMethod.cs

示例4: WriteNewMethodBody

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCodePart">
        /// </param>
        /// <param name="declaringTypeIn">
        /// </param>
        /// <param name="doNotCallInit">
        /// </param>
        /// <param name="doNotTestNullValue">
        /// </param>
        public static void WriteNewMethodBody(
            this LlvmWriter llvmWriter, OpCodePart opCodePart, IType declaringTypeIn, bool doNotCallInit = false, bool doNotTestNullValue = false)
        {
            var declaringClassType = declaringTypeIn.ToClass();

            var writer = llvmWriter.Output;

            writer.WriteLine("; New obj");

            llvmWriter.WriteAllocateMemoryForObject(opCodePart, declaringClassType, doNotTestNullValue);

            var castResult = opCodePart.Result;

            if (!doNotCallInit)
            {
                // llvmWriter.WriteInitObject(writer, opCode, declaringType);
                declaringClassType.WriteCallInitObjectMethod(llvmWriter, opCodePart);
            }

            // restore result and type
            opCodePart.Result = castResult;

            writer.WriteLine(string.Empty);
            writer.WriteLine("; end of new obj");
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:37,代码来源:ObjectInfrastructure.cs

示例5: WriteInit

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCodePart">
        /// </param>
        /// <param name="declaringTypeIn">
        /// </param>
        /// <param name="objectSource">
        /// </param>
        public static void WriteInit(this LlvmWriter llvmWriter, OpCodePart opCodePart, IType declaringTypeIn, FullyDefinedReference objectSource)
        {
            var writer = llvmWriter.Output;

            var declaringTypeNormal = declaringTypeIn.ToNormal();
            var declaringTypeClass = declaringTypeIn.IsValueType ? declaringTypeIn.ToClass() : declaringTypeIn;

            writer.WriteLine("; Init obj");

            if (declaringTypeNormal.IsValueType)
            {
                llvmWriter.WriteBitcast(opCodePart, objectSource, llvmWriter.ResolveType("System.Byte").ToPointerType());
                writer.WriteLine(string.Empty);

                llvmWriter.WriteMemSet(declaringTypeNormal, opCodePart.Result);
                writer.WriteLine(string.Empty);

                if (declaringTypeNormal.IsStructureType())
                {
                    // init now
                    opCodePart.Result = objectSource;

                    declaringTypeClass.WriteCallInitObjectMethod(llvmWriter, opCodePart);
                    writer.WriteLine(string.Empty);
                }
            }
            else
            {
                // this is type reference, initialize it with null
                llvmWriter.WriteBitcast(opCodePart, objectSource, llvmWriter.ResolveType("System.Byte").ToPointerType().ToPointerType());
                writer.WriteLine(string.Empty);

                writer.WriteLine("store i8* null, i8** {0}", opCodePart.Result);
            }

            writer.Write("; end of init obj");
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:47,代码来源:ObjectInfrastructure.cs

示例6: WriteGetHashCodeObjectForEnum

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="declaringType">
        /// </param>
        public static void WriteGetHashCodeObjectForEnum(this LlvmWriter llvmWriter, OpCodePart opCode, IType declaringType)
        {
            var writer = llvmWriter.Output;

            var isStruct = declaringType.IsStructureType();

            writer.WriteLine("; Returning Hash Code");
            writer.WriteLine(string.Empty);

            llvmWriter.CheckIfExternalDeclarationIsRequired(declaringType);

            writer.WriteLine("; Get data");

            if (!isStruct)
            {
                // write access to a field
                if (!llvmWriter.WriteFieldAccess(writer, opCode, declaringType.ToClass(), declaringType.ToClass(), 0, opCode.Result))
                {
                    writer.WriteLine("; No data");
                    return;
                }

                writer.WriteLine(string.Empty);
            }
            else
            {
                Debug.Fail("Not implemented yet");
                throw new NotImplementedException();
            }

            // load value from field
            var memberAccessResultNumber = opCode.Result;

            opCode.Result = null;
            llvmWriter.WriteLlvmLoad(opCode, memberAccessResultNumber.Type.ToNormal(), memberAccessResultNumber);
            writer.WriteLine(string.Empty);

            if (opCode.Result.Type.IntTypeBitSize() != llvmWriter.ResolveType("System.Int32").IntTypeBitSize())
            {
                var storeResult = opCode.Result;
                var retResult = llvmWriter.WriteSetResultNumber(opCode, llvmWriter.ResolveType("System.Int32"));
                opCode.Result = storeResult;
                llvmWriter.AdjustIntConvertableTypes(writer, opCode, llvmWriter.ResolveType("System.Int32"));
                opCode.Result = retResult;
                writer.WriteLine(string.Empty);
            }

            writer.WriteLine("; End of Getting data");
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:57,代码来源:ObjectInfrastructure.cs

示例7: WriteBoxObject

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="declaringType">
        /// </param>
        /// <param name="newObjectResult">
        /// </param>
        /// <param name="callInit">
        /// </param>
        public static void WriteBoxObject(
            this LlvmWriter llvmWriter, OpCodePart opCode, IType declaringType, FullyDefinedReference newObjectResult = null, bool callInit = false)
        {
            var writer = llvmWriter.Output;

            var valueLoadResult = opCode.Result;

            var isStruct = declaringType.ToNormal().IsStructureType();

            opCode.Result = null;

            writer.WriteLine("; Boxing");

            writer.WriteLine(string.Empty);
            llvmWriter.CheckIfExternalDeclarationIsRequired(declaringType);

            // call new if null
            if (newObjectResult == null)
            {
                declaringType.WriteCallNewObjectMethod(llvmWriter, opCode);
                newObjectResult = opCode.Result;
            }
            else
            {
                opCode.Result = newObjectResult;
            }

            writer.WriteLine(string.Empty);
            writer.WriteLine("; Copy data");

            if (!isStruct)
            {
                // write access to a field
                if (!llvmWriter.WriteFieldAccess(
                        writer, 
                        opCode, 
                        declaringType.ToClass(), 
                        declaringType.ToClass(), 
                        0, 
                        opCode.Result))
                {
                    writer.WriteLine("; No data");
                    return;
                }

                writer.WriteLine(string.Empty);
            }

            var fieldType = declaringType.ToNormal();

            opCode.OpCodeOperands = new[] { new OpCodePart(OpCodesEmit.Ldarg_0, 0, 0) };
            opCode.OpCodeOperands[0].Result = valueLoadResult;
            if (valueLoadResult == null)
            {
                llvmWriter.ActualWrite(writer, opCode.OpCodeOperands[0]);
            }

            llvmWriter.SaveToField(opCode, fieldType, 0);

            writer.WriteLine(string.Empty);
            writer.WriteLine("; End of Copy data");

            if (callInit)
            {
                opCode.Result = newObjectResult;
                declaringType.WriteCallInitObjectMethod(llvmWriter, opCode);
                writer.WriteLine(string.Empty);
            }

            opCode.Result = newObjectResult.ToClassType();
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:83,代码来源:ObjectInfrastructure.cs

示例8: WriteFunctionCallArguments

        /// <summary>
        /// </summary>
        /// <param name="parameterInfos">
        /// </param>
        /// <param name="used">
        /// </param>
        /// <param name="isVirtual">
        /// </param>
        /// <param name="hasThis">
        /// </param>
        /// <param name="isCtor">
        /// </param>
        /// <param name="resultNumberForThis">
        /// </param>
        /// <param name="thisType">
        /// </param>
        /// <param name="resultNumberForReturn">
        /// </param>
        /// <param name="returnType">
        /// </param>
        /// <param name="llvmWriter">
        /// </param>
        public static void WriteFunctionCallArguments(
            this IEnumerable<IParameter> parameterInfos,
            OpCodePart[] used,
            bool @isVirtual,
            bool hasThis,
            bool isCtor,
            FullyDefinedReference resultNumberForThis,
            IType thisType,
            FullyDefinedReference resultNumberForReturn,
            IType returnType,
            LlvmWriter llvmWriter,
            bool varArg)
        {
            var writer = llvmWriter.Output;

            writer.Write("(");

            var index = 0;

            var returnIsStruct = returnType != null && returnType.IsStructureType();

            var comaRequired = false;

            // allocate space for structure if return type is structure
            if (returnIsStruct)
            {
                returnType.WriteTypePrefix(llvmWriter, returnType.IsStructureType());
                writer.Write(' ');
                if (resultNumberForReturn != null)
                {
                    llvmWriter.WriteResult(resultNumberForReturn);
                }

                comaRequired = true;
            }

            if (hasThis)
            {
                if (comaRequired)
                {
                    writer.Write(", ");
                }

                thisType.ToClass().WriteTypePrefix(llvmWriter);
                writer.Write(' ');
                if (resultNumberForThis != null)
                {
                    llvmWriter.WriteResult(resultNumberForThis);
                }
                else if (used != null && used.Length > 0)
                {
                    llvmWriter.WriteResult(used[0].Result);
                }

                comaRequired = true;
            }

            llvmWriter.CheckIfExternalDeclarationIsRequired(returnType);

            var argsContainsThisArg = used != null ? (used.Length - parameterInfos.Count()) > 0 : false;
            var argShift = @isVirtual || (hasThis && !isCtor && argsContainsThisArg) ? 1 : 0;

            // add parameters
            foreach (var parameter in parameterInfos)
            {
                var effectiveIndex = index + argShift;
                var usedItem = used[effectiveIndex];

                if (comaRequired)
                {
                    writer.Write(", ");
                }

                llvmWriter.WriteFunctionCallParameterArgument(usedItem, parameter);

                comaRequired = true;
                index++;
            }
//.........这里部分代码省略.........
开发者ID:afrog33k,项目名称:csnative,代码行数:101,代码来源:CallGen.cs


注:本文中的IType.ToClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。