本文整理汇总了C#中Drivers.Compiler.IL.ILPreprocessState类的典型用法代码示例。如果您正苦于以下问题:C# ILPreprocessState类的具体用法?C# ILPreprocessState怎么用?C# ILPreprocessState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILPreprocessState类属于Drivers.Compiler.IL命名空间,在下文中一共展示了ILPreprocessState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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!");
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:30,代码来源:Ceq.cs
示例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
});
}
开发者ID:kztao,项目名称:FlingOS,代码行数:33,代码来源:Convu.cs
示例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
});
}
}
开发者ID:sramos30,项目名称:FlingOS,代码行数:30,代码来源:Ldfld.cs
示例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;
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:33,代码来源:Ldsfld.cs
示例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
});
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:30,代码来源:NewObj.cs
示例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
});
}
}
开发者ID:kztao,项目名称:FlingOS,代码行数:26,代码来源:Sub.cs
示例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
});
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:30,代码来源:Mul.cs
示例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
});
}
开发者ID:sramos30,项目名称:FlingOS,代码行数:35,代码来源:Ldind.cs
示例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
});
}
}
开发者ID:kztao,项目名称:FlingOS,代码行数:59,代码来源:Ldarg.cs
示例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();
}
}
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:57,代码来源:Call.cs
示例11: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false
});
}
开发者ID:kztao,项目名称:FlingOS,代码行数:9,代码来源:Sizeof.cs
示例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;
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:9,代码来源:Switch.cs
示例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
});
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:56,代码来源:Ldarg.cs
示例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();
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:10,代码来源:MethodEnd.cs
示例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
});
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:54,代码来源:Ldloc.cs
示例16: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
int metadataToken = Utilities.ReadInt32(theOp.ValueBytes, 0);
Type theType = conversionState.Input.TheMethodInfo.UnderlyingInfo.Module.ResolveType(metadataToken);
Types.TypeInfo theTypeInfo = conversionState.TheILLibrary.GetTypeInfo(theType);
int size = theTypeInfo.SizeOnStackInBytes;
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = size,
isGCManaged = false
});
}
开发者ID:kztao,项目名称:FlingOS,代码行数:14,代码来源:Ldobj.cs
示例17: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
try
{
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false
});
}
catch
{
throw new NotSupportedException("The metadata token specifies a fieldref or methodref which isn't supported yet!");
}
}
开发者ID:kztao,项目名称:FlingOS,代码行数:16,代码来源:Ldtoken.cs
示例18: PerformStackOperations
public override void PerformStackOperations(ILPreprocessState conversionState, ILOp theOp)
{
StackItem itemA = conversionState.CurrentStackFrame.Stack.Pop();
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = itemA.isFloat,
sizeOnStackInBytes = itemA.sizeOnStackInBytes,
isGCManaged = itemA.isGCManaged
});
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = itemA.isFloat,
sizeOnStackInBytes = itemA.sizeOnStackInBytes,
isGCManaged = itemA.isGCManaged
});
}
开发者ID:kztao,项目名称:FlingOS,代码行数:17,代码来源:Dup.cs
示例19: Preprocess
public override void Preprocess(ILPreprocessState preprocessState, ILOp theOp)
{
Types.MethodInfo methodInfo = preprocessState.TheILLibrary.GetMethodInfo(theOp.MethodToCall);
if (theOp.LoadAtILOpAfterOp != null)
{
ILBlock anILBlock = preprocessState.TheILLibrary.GetILBlock(methodInfo);
int index = anILBlock.ILOps.IndexOf(theOp.LoadAtILOpAfterOp);
index++;
anILBlock.ILOps[index].LabelRequired = true;
}
else if (theOp.LoadAtILOffset != int.MaxValue)
{
int offset = theOp.LoadAtILOffset;
ILOp theLoadedOp = preprocessState.TheILLibrary.GetILBlock(methodInfo).At(offset);
theLoadedOp.LabelRequired = true;
}
}
开发者ID:kztao,项目名称:FlingOS,代码行数:18,代码来源:Ldftn.cs
示例20: rotateStackItems
private static void rotateStackItems(ILPreprocessState state, int items, int distance)
{
if (distance >= items)
{
throw new IndexOutOfRangeException("IlPreprocessor.rotateStackItems: distance >= items invalid!");
}
List<StackItem> poppedItems = new List<StackItem>();
for (int i = 0; i < items; i++)
{
poppedItems.Add(state.CurrentStackFrame.Stack.Pop());
}
for (int i = distance; i > -1; i--)
{
state.CurrentStackFrame.Stack.Push(poppedItems[i]);
}
for (int i = items - 1; i > distance; i--)
{
state.CurrentStackFrame.Stack.Push(poppedItems[i]);
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:20,代码来源:StackSwitch.cs
注:本文中的Drivers.Compiler.IL.ILPreprocessState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论