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


C# IType.WriteTypePrefix方法代码示例

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


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

示例1: GetArrayTypeHeader

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="elementType">
        /// </param>
        /// <param name="length">
        /// </param>
        /// <returns>
        /// </returns>
        public static string GetArrayTypeHeader(this LlvmWriter llvmWriter, IType elementType, int length)
        {
            var typeString = llvmWriter.WriteToString(
                () =>
                    {
                        var writer = llvmWriter.Output;
                        elementType.WriteTypePrefix(writer);
                    });

            return "{ " + GetArrayPrefixDataType() + ", [" + length + " x " + typeString + "] }";
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:21,代码来源:ArraySingleDimensionGen.cs

示例2: WriteCast

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="fromType">
        /// </param>
        /// <param name="custromName">
        /// </param>
        /// <param name="toType">
        /// </param>
        /// <param name="appendReference">
        /// </param>
        /// <param name="doNotConvert">
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public static void WriteCast(
            this LlvmWriter llvmWriter,
            OpCodePart opCode,
            IType fromType,
            string custromName,
            IType toType,
            bool appendReference = false,
            bool doNotConvert = false)
        {
            // TODO: remove this one. use anather one
            var writer = llvmWriter.Output;

            if (!fromType.IsInterface && toType.IsInterface)
            {
                throw new NotImplementedException();

                ////opCode.Result = res;
                ////this.WriteInterfaceAccess(writer, opCode, fromType, toType);
            }
            llvmWriter.WriteSetResultNumber(opCode, toType);
            writer.Write("bitcast ");
            fromType.WriteTypePrefix(llvmWriter, true);
            writer.Write(' ');
            writer.Write(custromName);
            writer.Write(" to ");
            toType.WriteTypePrefix(llvmWriter, true);
            if (appendReference)
            {
                // result should be array
                writer.Write('*');
            }

            writer.WriteLine(string.Empty);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:52,代码来源:LlvmHelpersGen.cs

示例3: WriteBitcast

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="fromType">
        /// </param>
        /// <param name="result">
        /// </param>
        /// <param name="custom">
        /// </param>
        public static void WriteBitcast(
            this LlvmWriter llvmWriter,
            OpCodePart opCode,
            IType fromType,
            IncrementalResult result,
            string custom)
        {
            var writer = llvmWriter.Output;

            llvmWriter.WriteSetResultNumber(opCode, null);
            writer.Write("bitcast ");
            fromType.WriteTypePrefix(llvmWriter, true);
            writer.Write(' ');
            llvmWriter.WriteResult(result);
            writer.Write(" to ");
            writer.Write(custom);

            writer.WriteLine(string.Empty);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:31,代码来源:LlvmHelpersGen.cs

示例4: WriteAlloca

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

            // for value types
            writer.Write("alloca ");
            type.WriteTypePrefix(llvmWriter);
            writer.Write(", align " + LlvmWriter.PointerSize);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:15,代码来源:LlvmHelpersGen.cs

示例5: WriteFunctionCallVarArgument

        private static void WriteFunctionCallVarArgument(this LlvmWriter llvmWriter, OpCodePart opArg, IType type)
        {
            var writer = llvmWriter.Output;

            llvmWriter.CheckIfExternalDeclarationIsRequired(type);

            type.WriteTypePrefix(llvmWriter, type.IsStructureType());
            if (type.IsStructureType())
            {
                writer.Write(" byval align " + llvmWriter.ByValAlign);
            }

            writer.Write(' ');
            llvmWriter.WriteResult(opArg);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:15,代码来源:CallGen.cs

示例6: LlvmConvert

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="realConvert">
        /// </param>
        /// <param name="intConvert">
        /// </param>
        /// <param name="toType">
        /// </param>
        /// <param name="toAddress">
        /// </param>
        /// <param name="typesToExclude">
        /// </param>
        public static void LlvmConvert(
            this LlvmWriter llvmWriter,
            OpCodePart opCode,
            string realConvert,
            string intConvert,
            IType toType,
            bool toAddress,
            params IType[] typesToExclude)
        {
            var writer = llvmWriter.Output;

            var resultOf = llvmWriter.ResultOf(opCode.OpCodeOperands[0]);
            var areBothPointers = (resultOf.Type.IsPointer || resultOf.Type.IsByRef) && toAddress;
            var typeToTest = resultOf.Type.IsEnum ? resultOf.Type.GetEnumUnderlyingType() : resultOf.Type;
            if (!typesToExclude.Any(typeToTest.TypeEquals) && !areBothPointers)
            {
                if (resultOf.Type.IsReal())
                {
                    llvmWriter.UnaryOper(
                        writer,
                        opCode,
                        realConvert,
                        resultType: toType,
                        options: LlvmWriter.OperandOptions.GenerateResult);
                }
                else if (resultOf.Type.IsPointer || resultOf.Type.IsByRef)
                {
                    Debug.Assert(!toType.IsPointer);
                    llvmWriter.UnaryOper(
                        writer,
                        opCode,
                        "ptrtoint",
                        resultType: toType,
                        options: LlvmWriter.OperandOptions.GenerateResult);
                }
                else if (toType.IsPointer || toType.IsByRef)
                {
                    llvmWriter.UnaryOper(
                        writer,
                        opCode,
                        resultOf.Type.IsValueType() && !resultOf.Type.IsPointer && !resultOf.Type.IsByRef ? "inttoptr" : "bitcast",
                        resultType: toType,
                        options: LlvmWriter.OperandOptions.GenerateResult);
                }
                else
                {
                    var intSize = toType.IntTypeBitSize();
                    if (intSize > 0)
                    {
                        var toIntType = toType.IsUnsignedType()
                            ? llvmWriter.GetUIntTypeByByteSize(intSize / 8)
                            : llvmWriter.GetIntTypeByByteSize(intSize / 8);
                        if (llvmWriter.AdjustIntConvertableTypes(writer, opCode.OpCodeOperands[0], toIntType))
                        {
                            opCode.Result = opCode.OpCodeOperands[0].Result;
                            return;
                        }
                    }

                    // if types are equals then
                    if (opCode.OpCodeOperands[0].Result.Type.TypeEquals(toType))
                    {
                        opCode.Result = opCode.OpCodeOperands[0].Result;
                        return;
                    }

                    if (intSize == opCode.OpCodeOperands[0].Result.Type.IntTypeBitSize())
                    {
                        opCode.Result = opCode.OpCodeOperands[0].Result;
                        return;
                    }

                    llvmWriter.UnaryOper(
                        writer,
                        opCode,
                        intConvert,
                        resultType: toType,
                        options: LlvmWriter.OperandOptions.GenerateResult);
                }

                writer.Write(" to ");
                toType.WriteTypePrefix(llvmWriter);
            }
            else
//.........这里部分代码省略.........
开发者ID:afrog33k,项目名称:csnative,代码行数:101,代码来源:LlvmHelpersGen.cs

示例7: WriteLlvmSave

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="typeToSave">
        /// </param>
        /// <param name="operandIndex">
        /// </param>
        /// <param name="destination">
        /// </param>
        public static void WriteLlvmSave(
            this LlvmWriter llvmWriter,
            OpCodePart opCode,
            IType typeToSave,
            int operandIndex,
            FullyDefinedReference destination)
        {
            var writer = llvmWriter.Output;

            llvmWriter.ProcessOperator(
                writer,
                opCode,
                "store",
                typeToSave,
                options: LlvmWriter.OperandOptions.CastPointersToBytePointer | LlvmWriter.OperandOptions.AdjustIntTypes,
                operand1: operandIndex,
                operand2: -1);
            llvmWriter.WriteOperandResult(writer, opCode, operandIndex);
            writer.Write(", ");
            typeToSave.WriteTypePrefix(llvmWriter);
            writer.Write("* ");
            writer.Write(destination);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:35,代码来源:LlvmHelpersGen.cs

示例8: GetArrayValuesHeader

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="elementType">
        /// </param>
        /// <param name="length">
        /// </param>
        /// <param name="storeLength">
        /// </param>
        /// <returns>
        /// </returns>
        public static string GetArrayValuesHeader(
            this LlvmWriter llvmWriter,
            IType elementType,
            int length,
            int storeLength)
        {
            var typeString = llvmWriter.WriteToString(
                () =>
                {
                    var writer = llvmWriter.Output;
                    elementType.WriteTypePrefix(llvmWriter);
                });

            return GetSingleDimArrayPrefixNullConstData(llvmWriter) + ", i16 0, i16 " + elementType.GetTypeCode() +
                   ", i32 " + elementType.GetTypeSize(llvmWriter, true) + ", i32 " + storeLength + ", [" +
                   length + " x " + typeString + "]";
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:29,代码来源:ArraySingleDimensionGen.cs

示例9: WritePtrToInt

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

            llvmWriter.WriteSetResultNumber(opCode, toType);
            writer.Write("ptrtoint ");
            source.Type.WriteTypePrefix(writer, true);
            writer.Write(" ");
            llvmWriter.WriteResult(source);
            writer.Write(" to ");
            toType.WriteTypePrefix(writer);
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:22,代码来源:LlvmHelpersGen.cs

示例10: GetArrayValuesHeader

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="elementType">
        /// </param>
        /// <param name="length">
        /// </param>
        /// <param name="storeLength">
        /// </param>
        /// <returns>
        /// </returns>
        public static string GetArrayValuesHeader(this LlvmWriter llvmWriter, IType elementType, int length, int storeLength)
        {
            var typeString = llvmWriter.WriteToString(
                () =>
                    {
                        var writer = llvmWriter.Output;
                        elementType.WriteTypePrefix(writer);
                    });

            ////var arrayType = llvmWriter.ResolveType("System.Array");
            ////var cloneableType = llvmWriter.ResolveType("System.ICloneable");
            ////var listType = llvmWriter.ResolveType("System.Collections.IList");
            ////return "i8** " + arrayType.GetVirtualTableReference(llvmWriter) + ", i8** " + arrayType.GetVirtualTableReference(cloneableType) + ", i8** "
            ////       + arrayType.GetVirtualTableReference(listType) + ", i32 " + elementType.GetTypeSize(true) + ", i32 " + storeLength + ", [" + length + " x "
            ////       + typeString + "]";
            return "i8* null, i8* null, i8* null, i32 " + elementType.GetTypeSize(true) + ", i32 " + storeLength + ", [" + length + " x " + typeString + "]";
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:29,代码来源:ArraySingleDimensionGen.cs

示例11: WriteIntToPtr

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

            Debug.Assert(!source.Type.IsPointer && !source.Type.IsByRef);

            llvmWriter.WriteSetResultNumber(opCode, toType);
            writer.Write("inttoptr ");
            source.Type.WriteTypePrefix(llvmWriter);
            writer.Write(" ");
            llvmWriter.WriteResult(source);
            writer.Write(" to ");
            toType.WriteTypePrefix(llvmWriter, true);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:28,代码来源:LlvmHelpersGen.cs

示例12: LlvmIntConvert

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

            var incomingResult = opCode.Result;

            llvmWriter.ProcessOperator(
                writer,
                opCode,
                intConvert,
                opCode.Result.Type,
                toType,
                LlvmWriter.OperandOptions.GenerateResult);

            var returnResult = opCode.Result;

            opCode.Result = incomingResult;

            llvmWriter.WriteOperandResult(writer, opCode);

            writer.Write(" to ");
            toType.WriteTypePrefix(llvmWriter);

            opCode.Result = returnResult;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:39,代码来源:LlvmHelpersGen.cs

示例13: WriteLlvmLoad

        /// <summary>
        /// </summary>
        /// <param name="llvmWriter">
        /// </param>
        /// <param name="opCode">
        /// </param>
        /// <param name="typeToLoad">
        /// </param>
        /// <param name="source">
        /// </param>
        /// <param name="appendReference">
        /// </param>
        /// <param name="structAsRef">
        /// </param>
        /// <param name="indirect">
        /// </param>
        public static void WriteLlvmLoad(
            this LlvmWriter llvmWriter,
            OpCodePart opCode,
            IType typeToLoad,
            FullyDefinedReference source,
            bool appendReference = true,
            bool structAsRef = false,
            bool indirect = false)
        {
            // TODO: review the whole proc.
            var writer = llvmWriter.Output;

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

            Debug.Assert(
                structAsRef || !isStruct || typeToLoad.IsByRef || isStruct && !typeToLoad.IsByRef && opCode.HasResult);

            if (!isStruct || typeToLoad.IsByRef || structAsRef || !opCode.HasResult || (indirect && !isStruct))
            {
                ////Debug.Assert(source.Type.IsPointer);
                var dereferencedType = source.Type.IsPointer ? source.Type.GetElementType() : null;

                var effectiveSource = source;

                // check if you need bitcast pointer type
                if (!typeToLoad.IsPointer && dereferencedType != null && typeToLoad.TypeNotEquals(dereferencedType))
                {
                    // check if you need cast here
                    llvmWriter.WriteBitcast(opCode, source, typeToLoad);
                    writer.WriteLine(string.Empty);
                    effectiveSource = opCode.Result;
                }

                if (indirect && !source.Type.IsPointer && !source.Type.IsByRef && source.Type.IntTypeBitSize() > 0)
                {
                    // check if you need cast here
                    llvmWriter.WriteIntToPtr(opCode, source, typeToLoad);
                    writer.WriteLine(string.Empty);
                    effectiveSource = opCode.Result;
                }

                llvmWriter.WriteSetResultNumber(opCode, typeToLoad);

                // last part
                writer.Write("load ");
                typeToLoad.WriteTypePrefix(llvmWriter, structAsRef);
                if (appendReference)
                {
                    // add reference to type
                    writer.Write('*');
                }

                writer.Write(' ');
                writer.Write(effectiveSource.ToString());

                // TODO: optional do we need to calculate it propertly?
                writer.Write(", align " + LlvmWriter.PointerSize);
            }
            else
            {
                llvmWriter.WriteCopyStruct(writer, opCode, typeToLoad, source, opCode.Result);
            }
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:79,代码来源:LlvmHelpersGen.cs

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