本文整理汇总了C#中IType.TypeNotEquals方法的典型用法代码示例。如果您正苦于以下问题:C# IType.TypeNotEquals方法的具体用法?C# IType.TypeNotEquals怎么用?C# IType.TypeNotEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.TypeNotEquals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: WriteFunctionCallProlog
/// <summary>
/// </summary>
/// <param name="methodInfo">
/// </param>
/// <param name="opCodeMethodInfo">
/// </param>
/// <param name="isVirtual">
/// </param>
/// <param name="hasThis">
/// </param>
/// <param name="llvmWriter">
/// </param>
/// <param name="thisType">
/// </param>
/// <param name="hasThisArgument">
/// </param>
/// <param name="opCodeFirstOperand">
/// </param>
/// <param name="resultOfFirstOperand">
/// </param>
/// <param name="isIndirectMethodCall">
/// </param>
/// <param name="ownerOfExplicitInterface">
/// </param>
/// <param name="requiredType">
/// </param>
public static void WriteFunctionCallProlog(
this IMethod methodInfo,
OpCodePart opCodeMethodInfo,
bool isVirtual,
bool hasThis,
LlvmWriter llvmWriter,
out IType thisType,
out bool hasThisArgument,
out OpCodePart opCodeFirstOperand,
out BaseWriter.ReturnResult resultOfFirstOperand,
out bool isIndirectMethodCall,
out IType ownerOfExplicitInterface,
out IType requiredType)
{
thisType = methodInfo.DeclaringType.ToClass();
hasThisArgument = hasThis && opCodeMethodInfo.OpCodeOperands != null
&& opCodeMethodInfo.OpCodeOperands.Length - methodInfo.GetParameters().Count() > 0;
opCodeFirstOperand = opCodeMethodInfo.OpCodeOperands != null && opCodeMethodInfo.OpCodeOperands.Length > 0
? opCodeMethodInfo.OpCodeOperands[0]
: null;
resultOfFirstOperand = opCodeFirstOperand != null ? llvmWriter.ResultOf(opCodeFirstOperand) : null;
isIndirectMethodCall = isVirtual
&&
(methodInfo.IsAbstract || methodInfo.IsVirtual ||
(thisType.IsInterface && thisType.TypeEquals(resultOfFirstOperand.Type)));
ownerOfExplicitInterface = isVirtual && thisType.IsInterface &&
thisType.TypeNotEquals(resultOfFirstOperand.Type)
? resultOfFirstOperand.Type
: null;
var rollbackType = false;
requiredType = ownerOfExplicitInterface != null ? resultOfFirstOperand.Type : null;
if (requiredType != null)
{
thisType = requiredType;
rollbackType = true;
}
if (isIndirectMethodCall && methodInfo.DeclaringType.TypeNotEquals(thisType) &&
methodInfo.DeclaringType.IsInterface && !thisType.IsInterface
&& thisType.HasExplicitInterfaceMethodOverride(methodInfo))
{
// this is explicit call of interface
isIndirectMethodCall = false;
}
else if (rollbackType)
{
thisType = methodInfo.DeclaringType;
}
}