本文整理汇总了C#中Drivers.Compiler.IL.ILPreprocessState类的典型用法代码示例。如果您正苦于以下问题:C# ILPreprocessState类的具体用法?C# ILPreprocessState怎么用?C# ILPreprocessState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILPreprocessState类属于Drivers.Compiler.IL命名空间,在下文中一共展示了ILPreprocessState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
StackItem itemB = conversionState.CurrentStackFrame.Stack.Pop();
StackItem itemA = conversionState.CurrentStackFrame.Stack.Pop();
if (itemA.sizeOnStackInBytes == 4 && itemB.sizeOnStackInBytes == 4)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false,
isValue = true
});
}
else if (itemA.sizeOnStackInBytes == 8 && itemB.sizeOnStackInBytes == 8)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false,
isValue = true
});
}
else
{
throw new NotSupportedException("Unsupported number of bytes for compare equal to!");
}
}
示例2: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
StackItem itemToConvert = conversionState.CurrentStackFrame.Stack.Pop();
int numBytesToConvertTo = 0;
switch ((OpCodes)theOp.opCode.Value)
{
case OpCodes.Conv_U:
numBytesToConvertTo = 4;
break;
case OpCodes.Conv_U1:
numBytesToConvertTo = 1;
break;
case OpCodes.Conv_U2:
numBytesToConvertTo = 2;
break;
case OpCodes.Conv_U4:
numBytesToConvertTo = 4;
break;
case OpCodes.Conv_U8:
numBytesToConvertTo = 8;
break;
}
bool pushEDX = numBytesToConvertTo == 8;
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
sizeOnStackInBytes = (pushEDX ? 8 : 4),
isFloat = false,
isGCManaged = false
});
}
示例3: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
int metadataToken = Utilities.ReadInt32(theOp.ValueBytes, 0);
FieldInfo theField = conversionState.Input.TheMethodInfo.UnderlyingInfo.Module.ResolveField(metadataToken);
bool valueisFloat = Utilities.IsFloat(theField.FieldType);
Types.TypeInfo fieldTypeInfo = conversionState.TheILLibrary.GetTypeInfo(theField.FieldType);
int stackSize = fieldTypeInfo.SizeOnStackInBytes;
StackItem objPointer = conversionState.CurrentStackFrame.Stack.Pop();
if ((OpCodes)theOp.opCode.Value == OpCodes.Ldflda)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false
});
}
else
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = valueisFloat,
sizeOnStackInBytes = stackSize,
isGCManaged = fieldTypeInfo.IsGCManaged
});
}
}
示例4: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
int metadataToken = Utilities.ReadInt32(theOp.ValueBytes, 0);
FieldInfo theField = conversionState.Input.TheMethodInfo.UnderlyingInfo.Module.ResolveField(metadataToken);
switch ((OpCodes)theOp.opCode.Value)
{
case OpCodes.Ldsfld:
{
Types.TypeInfo theTypeInfo = conversionState.TheILLibrary.GetTypeInfo(theField.FieldType);
int size = theTypeInfo.SizeOnStackInBytes;
bool isFloat = Utilities.IsFloat(theField.FieldType);
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = isFloat,
sizeOnStackInBytes = (size == 8 ? 8 : 4),
isGCManaged = theTypeInfo.IsGCManaged,
isValue = theTypeInfo.IsValueType
});
}
break;
case OpCodes.Ldsflda:
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false,
isValue = false
});
break;
}
}
示例5: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
MethodBase constructorMethod = theOp.MethodToCall;
Type objectType = constructorMethod.DeclaringType;
if (typeof(Delegate).IsAssignableFrom(objectType))
{
StackItem funcPtrItem = conversionState.CurrentStackFrame.Stack.Pop(); ;
conversionState.CurrentStackFrame.Stack.Pop();
conversionState.CurrentStackFrame.Stack.Push(funcPtrItem);
return;
}
Types.MethodInfo constructorMethodInfo = conversionState.TheILLibrary.GetMethodInfo(constructorMethod);
ParameterInfo[] allParams = constructorMethod.GetParameters();
foreach (ParameterInfo aParam in allParams)
{
conversionState.CurrentStackFrame.Stack.Pop();
}
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isNewGCObject = true,
isGCManaged = true,
isValue = false
});
}
示例6: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
StackItem itemB = conversionState.CurrentStackFrame.Stack.Pop();
StackItem itemA = conversionState.CurrentStackFrame.Stack.Pop();
if (itemA.sizeOnStackInBytes == 4 &&
itemB.sizeOnStackInBytes == 4)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false
});
}
else if (itemA.sizeOnStackInBytes == 8 &&
itemB.sizeOnStackInBytes == 8)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 8,
isGCManaged = false
});
}
}
示例7: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
//Pop in reverse order to push
StackItem itemB = conversionState.CurrentStackFrame.Stack.Pop();
StackItem itemA = conversionState.CurrentStackFrame.Stack.Pop();
if (itemA.sizeOnStackInBytes == 4 &&
itemB.sizeOnStackInBytes == 4)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false,
isValue = itemA.isValue && itemB.isValue
});
}
else if (itemA.sizeOnStackInBytes == 8 &&
itemB.sizeOnStackInBytes == 8)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
isNewGCObject = false,
sizeOnStackInBytes = 8,
isGCManaged = false,
isValue = itemA.isValue && itemB.isValue
});
}
}
示例8: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
StackItem addressItem = conversionState.CurrentStackFrame.Stack.Pop();
int bytesToLoad = 0;
switch ((OpCodes)theOp.opCode.Value)
{
case OpCodes.Ldind_U1:
case OpCodes.Ldind_I1:
bytesToLoad = 1;
break;
case OpCodes.Ldind_U2:
case OpCodes.Ldind_I2:
bytesToLoad = 2;
break;
case OpCodes.Ldind_U4:
case OpCodes.Ldind_I4:
case OpCodes.Ldind_I:
bytesToLoad = 4;
break;
case OpCodes.Ldind_I8:
bytesToLoad = 8;
break;
case OpCodes.Ldind_Ref:
bytesToLoad = Options.AddressSizeInBytes;
break;
}
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
sizeOnStackInBytes = bytesToLoad == 8 ? 8 : 4,
isFloat = false,
isGCManaged = false
});
}
示例9: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
Int16 index = 0;
switch ((OpCodes)theOp.opCode.Value)
{
case OpCodes.Ldarg:
index = Utilities.ReadInt16(theOp.ValueBytes, 0);
break;
case OpCodes.Ldarg_0:
index = 0;
break;
case OpCodes.Ldarg_1:
index = 1;
break;
case OpCodes.Ldarg_2:
index = 2;
break;
case OpCodes.Ldarg_3:
index = 3;
break;
case OpCodes.Ldarg_S:
index = (Int16)theOp.ValueBytes[0];
break;
case OpCodes.Ldarga:
index = Utilities.ReadInt16(theOp.ValueBytes, 0);
break;
case OpCodes.Ldarga_S:
index = (Int16)theOp.ValueBytes[0];
break;
}
List<Type> allParams = conversionState.Input.TheMethodInfo.UnderlyingInfo.GetParameters().Select(x => x.ParameterType).ToList();
if (!conversionState.Input.TheMethodInfo.IsStatic)
{
allParams.Insert(0, conversionState.Input.TheMethodInfo.UnderlyingInfo.DeclaringType);
}
if ((OpCodes)theOp.opCode.Value == OpCodes.Ldarga ||
(OpCodes)theOp.opCode.Value == OpCodes.Ldarga_S)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
sizeOnStackInBytes = 4,
isFloat = false,
isGCManaged = false
});
}
else
{
Types.TypeInfo paramTypeInfo = conversionState.TheILLibrary.GetTypeInfo(allParams[index]);
int bytesForArg = paramTypeInfo.SizeOnStackInBytes;
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
sizeOnStackInBytes = bytesForArg,
isFloat = false,
isGCManaged = paramTypeInfo.IsGCManaged
});
}
}
示例10: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
MethodBase methodToCall = theOp.MethodToCall;
Types.MethodInfo methodToCallInfo = conversionState.TheILLibrary.GetMethodInfo(methodToCall);
if (methodToCall is MethodInfo)
{
Type retType = ((MethodInfo)methodToCall).ReturnType;
Types.TypeInfo retTypeInfo = conversionState.TheILLibrary.GetTypeInfo(retType);
StackItem returnItem = new StackItem()
{
isFloat = Utilities.IsFloat(retType),
sizeOnStackInBytes = retTypeInfo.SizeOnStackInBytes,
isGCManaged = retTypeInfo.IsGCManaged,
isValue = retTypeInfo.IsValueType
};
int bytesToAdd = 0;
List<Type> allParams = ((MethodInfo)methodToCall).GetParameters().Select(x => x.ParameterType).ToList();
if (!methodToCall.IsStatic)
{
allParams.Insert(0, methodToCall.DeclaringType);
}
foreach (Type aParam in allParams)
{
conversionState.CurrentStackFrame.Stack.Pop();
bytesToAdd += conversionState.TheILLibrary.GetTypeInfo(aParam).SizeOnStackInBytes;
}
if (bytesToAdd > 0)
{
if (returnItem.sizeOnStackInBytes != 0)
{
conversionState.CurrentStackFrame.Stack.Push(returnItem);
}
}
else if (returnItem.sizeOnStackInBytes != 0)
{
conversionState.CurrentStackFrame.Stack.Push(returnItem);
}
}
else if (methodToCall is ConstructorInfo)
{
ConstructorInfo aConstructor = (ConstructorInfo)methodToCall;
if (aConstructor.IsStatic)
{
//Static constructors do not have parameters or return values
}
else
{
ParameterInfo[] allParams = methodToCall.GetParameters();
foreach (ParameterInfo aParam in allParams)
{
conversionState.CurrentStackFrame.Stack.Pop();
}
}
}
}
示例11: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false
});
}
示例12: Preprocess
public override void Preprocess(ILPreprocessState preprocessState, ILOp theOp)
{
for (int i = 0; i < theOp.ValueBytes.Length / 4; i++)
{
int branchOffset = theOp.NextOffset + Utilities.ReadInt32(theOp.ValueBytes, i * 4);
ILOp opToGoTo = preprocessState.Input.At(branchOffset);
opToGoTo.LabelRequired = true;
}
}
示例13: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
Int16 index = 0;
switch ((OpCodes)theOp.opCode.Value)
{
case OpCodes.Ldarg:
index = Utilities.ReadInt16(theOp.ValueBytes, 0);
break;
case OpCodes.Ldarg_0:
index = 0;
break;
case OpCodes.Ldarg_1:
index = 1;
break;
case OpCodes.Ldarg_2:
index = 2;
break;
case OpCodes.Ldarg_3:
index = 3;
break;
case OpCodes.Ldarg_S:
index = (Int16)theOp.ValueBytes[0];
break;
case OpCodes.Ldarga:
index = Utilities.ReadInt16(theOp.ValueBytes, 0);
break;
case OpCodes.Ldarga_S:
index = (Int16)theOp.ValueBytes[0];
break;
}
if ((OpCodes)theOp.opCode.Value == OpCodes.Ldarga ||
(OpCodes)theOp.opCode.Value == OpCodes.Ldarga_S)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
sizeOnStackInBytes = 4,
isFloat = false,
isGCManaged = false,
isValue = false
});
}
else
{
Types.VariableInfo argInfo = conversionState.Input.TheMethodInfo.ArgumentInfos[index];
Types.TypeInfo paramTypeInfo = argInfo.TheTypeInfo;
int bytesForArg = paramTypeInfo.SizeOnStackInBytes;
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
sizeOnStackInBytes = bytesForArg,
isFloat = false,
isGCManaged = paramTypeInfo.IsGCManaged,
isValue = paramTypeInfo.IsValueType
});
}
}
示例14: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
Type retType = (conversionState.Input.TheMethodInfo.IsConstructor ?
typeof(void) : ((MethodInfo)conversionState.Input.TheMethodInfo.UnderlyingInfo).ReturnType);
Types.TypeInfo retTypeInfo = conversionState.TheILLibrary.GetTypeInfo(retType);
if (retTypeInfo.SizeOnStackInBytes != 0)
{
conversionState.CurrentStackFrame.Stack.Pop();
}
}
示例15: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
bool loadAddr = (ILOp.OpCodes)theOp.opCode.Value == OpCodes.Ldloca ||
(ILOp.OpCodes)theOp.opCode.Value == OpCodes.Ldloca_S;
UInt16 localIndex = 0;
switch ((ILOp.OpCodes)theOp.opCode.Value)
{
case OpCodes.Ldloc:
case OpCodes.Ldloca:
localIndex = (UInt16)Utilities.ReadInt16(theOp.ValueBytes, 0);
break;
case OpCodes.Ldloc_0:
localIndex = 0;
break;
case OpCodes.Ldloc_1:
localIndex = 1;
break;
case OpCodes.Ldloc_2:
localIndex = 2;
break;
case OpCodes.Ldloc_3:
localIndex = 3;
break;
case OpCodes.Ldloc_S:
case OpCodes.Ldloca_S:
localIndex = (UInt16)theOp.ValueBytes[0];
break;
}
Types.VariableInfo theLoc = conversionState.Input.TheMethodInfo.LocalInfos.ElementAt(localIndex);
if (loadAddr)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false,
isValue = false
});
}
else
{
int pushedLocalSizeVal = theLoc.TheTypeInfo.SizeOnStackInBytes;
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = Utilities.IsFloat(theLoc.UnderlyingType),
sizeOnStackInBytes = pushedLocalSizeVal,
isGCManaged = theLoc.TheTypeInfo.IsGCManaged,
isValue = theLoc.TheTypeInfo.IsValueType
});
}
}