本文整理汇总了C#中Drivers.Compiler.IL.ILOp类的典型用法代码示例。如果您正苦于以下问题:C# ILOp类的具体用法?C# ILOp怎么用?C# ILOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILOp类属于Drivers.Compiler.IL命名空间,在下文中一共展示了ILOp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
/// <exception cref="System.NotSupportedException">
/// Thrown if either or both values to not are floating point values or
/// if the values are 8 bytes in size.
/// </exception>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
//Pop item to negate
StackItem itemA = conversionState.CurrentStackFrame.Stack.Peek();
if (itemA.isFloat)
{
//SUPPORT - floats
throw new NotSupportedException("Negate float vals not suppported yet!");
}
if (itemA.sizeOnStackInBytes == 4)
{
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Word, Dest = "$t0" });
//To not, arg Xor -1
conversionState.Append(new ASMOps.Mov() { Dest = "$t4", Src = "0xFFFFFFFF", MoveType = ASMOps.Mov.MoveTypes.ImmediateToReg });
conversionState.Append(new ASMOps.Xor() { Dest = "$t0", Src1 = "$t0", Src2 = "$t4" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Word, Src = "$t0" });
}
else if (itemA.sizeOnStackInBytes == 8)
{
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Word, Dest = "$t0" });
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Word, Dest = "$t3" });
conversionState.Append(new ASMOps.Mov() { Dest = "$t4", Src = "0xFFFFFFFF", MoveType = ASMOps.Mov.MoveTypes.ImmediateToReg });
conversionState.Append(new ASMOps.Xor() { Dest = "$t0", Src1 = "$t0", Src2 = "$t4" });
conversionState.Append(new ASMOps.Xor() { Dest = "$t3", Src1 = "$t3", Src2 = "$t4" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Word, Src = "$t3" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Word, Src = "$t0" });
}
else
{
throw new NotSupportedException("Stack item size not supported by neg op!");
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:44,代码来源:Not.cs
示例2: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
/// <exception cref="System.NotSupportedException">
/// Thrown when loading a static float field.
/// </exception>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
//Load static field
//Load the metadata token used to get the type info
int metadataToken = Utilities.ReadInt32(theOp.ValueBytes, 0);
//Get the type info for the object to load
Type theType = conversionState.Input.TheMethodInfo.UnderlyingInfo.Module.ResolveType(metadataToken);
Types.TypeInfo theTypeInfo = conversionState.TheILLibrary.GetTypeInfo(theType);
//Get the object size information
int size = theTypeInfo.SizeOnStackInBytes;
//Load the object onto the stack
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Dword, Dest = "ECX" });
for (int i = size - 4; i >= 0; i -= 4)
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "[ECX+" + i.ToString() + "]", Dest = "EAX" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = "EAX" });
}
int extra = size % 4;
for (int i = extra - 1; i >= 0; i--)
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Byte, Src = "[ECX+" + i.ToString() + "]", Dest = "AL" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Byte, Src = "AL" });
}
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = size,
isGCManaged = false
});
}
开发者ID:sramos30,项目名称:FlingOS,代码行数:43,代码来源:Ldobj.cs
示例3: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
/// <exception cref="System.NotSupportedException">
/// Thrown if divide operands are floating point numbers or if attempting to divide 64-bit numbers.
/// </exception>
/// <exception cref="System.InvalidOperationException">
/// Thrown if either operand is < 4 bytes long.
/// </exception>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
StackItem testItem = conversionState.CurrentStackFrame.Stack.Pop();
if (testItem.isFloat)
{
//TODO - Support floats
throw new NotSupportedException("Switch for floats no supported!");
}
else if (testItem.sizeOnStackInBytes != 4)
{
//TODO - Support other sizes
throw new NotSupportedException("Switch for non-int32s not supported!");
}
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Dword, Dest = "EAX" });
for (int i = 0; i < theOp.ValueBytes.Length / 4; i++)
{
int branchOffset = theOp.NextOffset + Utilities.ReadInt32(theOp.ValueBytes, i * 4);
ILOp opToGoTo = conversionState.Input.At(branchOffset);
int branchPos = conversionState.PositionOf(opToGoTo);
conversionState.Append(new ASMOps.Cmp() { Arg1 = "EAX", Arg2 = i.ToString() });
conversionState.Append(new ASMOps.Jmp() { JumpType = ASMOps.JmpOp.JumpEqual, DestILPosition = branchPos });
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:38,代码来源:Switch.cs
示例4: InsertPageFaultDetection
public static void InsertPageFaultDetection(ILConversionState conversionState, string reg, int offset, ILOp.OpCodes opCode)
{
if (PageFaultDetectionEnabled)
{
conversionState.Append(new ASMOps.Call() { Target = PageFaultDetectionMethod });
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:7,代码来源:GlobalMethods.cs
示例5: 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
示例6: 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
示例7: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
/// <exception cref="System.NotSupportedException">
/// Thrown when the metadata token is not for method metadata.
/// </exception>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
//Load token i.e. typeref
//It should also support methodref and fieldrefs
int metadataToken = Utilities.ReadInt32(theOp.ValueBytes, 0);
try
{
Type theType = conversionState.Input.TheMethodInfo.UnderlyingInfo.Module.ResolveType(metadataToken);
if (theType == null)
{
throw new NullReferenceException();
}
string typeTableId = conversionState.TheILLibrary.GetTypeInfo(theType).ID;
conversionState.AddExternalLabel(typeTableId);
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = typeTableId });
conversionState.CurrentStackFrame.Stack.Push(new StackItem()
{
isFloat = false,
sizeOnStackInBytes = 4,
isGCManaged = false,
isValue = false
});
}
catch
{
throw new NotSupportedException("The metadata token specifies a fieldref or methodref which isn't supported yet!");
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:40,代码来源:Ldtoken.cs
示例8: 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
示例9: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
/// <exception cref="System.NotSupportedException">
/// Thrown if either or both values to shift left are floating point values or
/// if the values are 8 bytes in size.
/// </exception>
/// <exception cref="System.InvalidOperationException">
/// Thrown if either or both values to multiply are not 4 or 8 bytes
/// in size or if the values are of different size.
/// </exception>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
StackItem theItem = conversionState.CurrentStackFrame.Stack.Peek();
if (theItem.isFloat)
{
//SUPPORT - Not op for floats
throw new NotSupportedException("Not op not supported for float operands!");
}
if (theItem.sizeOnStackInBytes == 4)
{
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Dword, Dest = "EAX" });
conversionState.Append(new ASMOps.Not() { Dest = "EAX" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = "EAX" });
}
else if (theItem.sizeOnStackInBytes == 8)
{
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Dword, Dest = "EAX" });
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Dword, Dest = "EBX" });
conversionState.Append(new ASMOps.Not() { Dest = "EAX" });
conversionState.Append(new ASMOps.Not() { Dest = "EBX" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = "EBX" });
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = "EAX" });
}
else
{
throw new NotSupportedException("Not op not supported for operand size!");
}
}
开发者ID:kztao,项目名称:FlingOS,代码行数:43,代码来源:Not.cs
示例10: 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
示例11: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
int dwordsToRotate = theOp.ValueBytes == null ? 2 : BitConverter.ToInt32(theOp.ValueBytes, 0);
int bytesShift = 0;
for (int i = 0; i < dwordsToRotate; i++)
{
if (i == 0)
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "[ESP+" + bytesShift.ToString() + "]", Dest = "EAX" });
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "[ESP+" + (bytesShift + 4).ToString() + "]", Dest = "EBX" });
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "EBX", Dest = "[ESP+" + bytesShift.ToString() + "]" });
}
else if (i == dwordsToRotate - 1)
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "EAX", Dest = "[ESP+" + bytesShift.ToString() + "]" });
}
else
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "[ESP+" + (bytesShift + 4).ToString() + "]", Dest = "EBX" });
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "EBX", Dest = "[ESP+" + bytesShift.ToString() + "]" });
}
bytesShift += 4;
}
rotateStackItems(conversionState, theOp.StackSwitch_Items, 1);
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:33,代码来源:StackSwitch.cs
示例12: Convert
/// <summary>
/// See base class documentation.
/// <para>To Do's:</para>
/// <list type="bullet">
/// <item>
/// <term>To do</term>
/// <description>Implement storing of float arguments.</description>
/// </item>
/// </list>
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
/// <exception cref="System.NotImplementedException">
/// Thrown when storing a float argument is required as it currently hasn't been
/// implemented.
/// </exception>
/// <exception cref="System.ArgumentException">
/// Thrown when an invalid number of bytes is specified for the argument to store.
/// </exception>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
//Get the index of the argument to load
Int16 index = 0;
switch ((OpCodes)theOp.opCode.Value)
{
case OpCodes.Starg:
index = Utilities.ReadInt16(theOp.ValueBytes, 0);
break;
case OpCodes.Starg_S:
index = (Int16)theOp.ValueBytes[0];
break;
}
Types.VariableInfo argInfo = conversionState.Input.TheMethodInfo.ArgumentInfos[index];
//Used to store the number of bytes to add to EBP to get to the arg
int BytesOffsetFromEBP = argInfo.Offset;
//Pop the argument value from the stack
int bytesForArg = argInfo.TheTypeInfo.SizeOnStackInBytes;
for (int i = 0; i < bytesForArg; i += 4)
{
conversionState.Append(new ASMOps.Pop() { Size = ASMOps.OperandSize.Dword, Dest = "[EBP+" + (BytesOffsetFromEBP+i) + "]" });
}
//Pop the arg value from our stack
conversionState.CurrentStackFrame.Stack.Pop();
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:48,代码来源:Starg.cs
示例13: Convert
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
//Save return address
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Word, Src = "$ra" });
//Push the previous method's fp
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Word, Src = "$fp" });
//Set fp for this method
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = "$sp", Dest = "$fp", MoveType = ASMOps.Mov.MoveTypes.RegToReg });
//Allocate stack space for locals
//Only bother if there are any locals
if (conversionState.Input.TheMethodInfo.LocalInfos.Count > 0)
{
int totalBytes = 0;
foreach (Types.VariableInfo aLocal in conversionState.Input.TheMethodInfo.LocalInfos)
{
totalBytes += aLocal.TheTypeInfo.SizeOnStackInBytes;
}
//We do not use "sub esp, X" (see below) because that leaves
//junk memory - we need memory to be "initialised" to 0
//so that local variables are null unless properly initialised.
//This prevents errors in the GC.
for (int i = 0; i < totalBytes / 4; i++)
{
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Word, Src = "$zero" });
}
//result.AppendLine(string.Format("sub esp, {0}", totalBytes));
}
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:29,代码来源:MethodStart.cs
示例14: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
//Push the previous method's ebp
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = "EBP" });
//Set ebp for this method
//See calling convention spec - this allows easy access of
//args and locals within the method without having to track
//temporary values (which would be a nightmare with the
//exception handling implementation that the kernel uses!)
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Dword, Src = "ESP", Dest = "EBP" });
//Allocate stack space for locals
//Only bother if there are any locals
if (conversionState.Input.TheMethodInfo.LocalInfos.Count > 0)
{
int totalBytes = 0;
foreach (Types.VariableInfo aLocal in conversionState.Input.TheMethodInfo.LocalInfos)
{
totalBytes += aLocal.TheTypeInfo.SizeOnStackInBytes;
}
//We do not use "sub esp, X" (see below) because that leaves
//junk memory - we need memory to be "initialised" to 0
//so that local variables are null unless properly initialised.
//This prevents errors in the GC.
for (int i = 0; i < totalBytes / 4; i++)
{
conversionState.Append(new ASMOps.Push() { Size = ASMOps.OperandSize.Dword, Src = "0" });
}
//result.AppendLine(string.Format("sub esp, {0}", totalBytes));
}
}
开发者ID:kztao,项目名称:FlingOS,代码行数:37,代码来源:MethodStart.cs
示例15: 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
示例16: 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
示例17: 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
示例18: 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
示例19: Convert
/// <summary>
/// See base class documentation.
/// </summary>
/// <param name="theOp">See base class documentation.</param>
/// <param name="conversionState">See base class documentation.</param>
/// <returns>See base class documentation.</returns>
public override void Convert(ILConversionState conversionState, ILOp theOp)
{
int dwordsToRotate = theOp.ValueBytes == null ? 2 : BitConverter.ToInt32(theOp.ValueBytes, 0);
int bytesShift = 0;
for (int i = 0; i < dwordsToRotate; i++)
{
if (i == 0)
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = bytesShift.ToString() + "($sp)", Dest = "$t0", MoveType = ASMOps.Mov.MoveTypes.SrcMemoryToDestReg });
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = (bytesShift + 4).ToString() + "($sp)", Dest = "$t1", MoveType = ASMOps.Mov.MoveTypes.SrcMemoryToDestReg });
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = "$t1", Dest = bytesShift.ToString() + "($sp)", MoveType = ASMOps.Mov.MoveTypes.SrcRegToDestMemory });
}
else if (i == dwordsToRotate - 1)
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = "$t0", Dest = bytesShift + "($sp)", MoveType = ASMOps.Mov.MoveTypes.SrcRegToDestMemory });
}
else
{
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = (bytesShift + 4).ToString() + "($sp)", Dest = "$t1", MoveType = ASMOps.Mov.MoveTypes.SrcMemoryToDestReg });
conversionState.Append(new ASMOps.Mov() { Size = ASMOps.OperandSize.Word, Src = "$t1", Dest = bytesShift.ToString() + "($sp)", MoveType = ASMOps.Mov.MoveTypes.SrcRegToDestMemory });
}
bytesShift += 4;
}
rotateStackItems(conversionState, theOp.StackSwitch_Items, 1);
}
开发者ID:rmhasan,项目名称:FlingOS,代码行数:33,代码来源:StackSwitch.cs
示例20: 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
注:本文中的Drivers.Compiler.IL.ILOp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论