This commit is contained in:
kudzu_cp 2009-07-24 15:31:09 +00:00
parent ecfd73e408
commit b2aea832cd
5 changed files with 25 additions and 8 deletions

View file

@ -51,6 +51,7 @@
<ItemGroup>
<Compile Include="ILOp.cs" />
<Compile Include="ILOpCode.cs" />
<Compile Include="ILOpCodes\InlineI.cs" />
<Compile Include="ILOpCodes\InlineNone.cs" />
<Compile Include="ILReader.cs" />
<Compile Include="OpCodeAttribute.cs" />

View file

@ -12,10 +12,10 @@ namespace Cosmos.IL2CPU {
//TODO: Change this to an abstract class and make constructor protected
public class ILOpCode {
public readonly Code Value;
public readonly Code OpCode;
public ILOpCode(Code aValue) {
Value = aValue;
public ILOpCode(Code aOpCode) {
OpCode = aOpCode;
}
//TODO: Use System.Reflection.Emit.OpCodes where possible, but we still need these

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cosmos.IL2CPU.ILOpCodes {
public class InlineI : ILOpCode {
public readonly UInt32 Value;
public InlineI(Code aOpCode, UInt32 aValue)
: base(aOpCode) {
Value = aValue;
}
}
}

View file

@ -6,7 +6,8 @@ using System.Text;
namespace Cosmos.IL2CPU.ILOpCodes {
public class InlineNone : ILOpCode {
public InlineNone(Code aValue) : base(aValue) {
public InlineNone(Code aOpCode)
: base(aOpCode) {
}
}

View file

@ -96,7 +96,7 @@ namespace Cosmos.IL2CPU {
// The operand is a 32-bit integer.
case OperandType.InlineI:
xOperandSize = 4;
xILOpCode = new ILOpCode(xOpCodeVal);
xILOpCode = new ILOpCodes.InlineI(xOpCodeVal, ReadInt32(xIL, 1));
break;
// The operand is a 64-bit integer.
case OperandType.InlineI8:
@ -131,7 +131,7 @@ namespace Cosmos.IL2CPU {
break;
case OperandType.InlineSwitch: {
int xCount = ReadInt32(xIL, 1);
int xCount = (int)ReadInt32(xIL, 1);
int[] xBranchLocations = new int[xCount];
uint[] xBranchValues = new uint[xCount];
for (int i = 0; i < xCount; i++) {
@ -204,8 +204,8 @@ namespace Cosmos.IL2CPU {
return xResult;
}
private Int32 ReadInt32(byte[] aBytes, int aPos) {
return (aBytes[aPos + 3] << 24 | aBytes[aPos + 2] << 16 | aBytes[aPos + 1] << 8 | aBytes[aPos]);
private UInt32 ReadInt32(byte[] aBytes, int aPos) {
return (UInt32)(aBytes[aPos + 3] << 24 | aBytes[aPos + 2] << 16 | aBytes[aPos + 1] << 8 | aBytes[aPos]);
}
//mOperandValueStr = mModule.ResolveString(OperandValueInt32);