mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
This commit is contained in:
parent
ecfd73e408
commit
b2aea832cd
5 changed files with 25 additions and 8 deletions
|
|
@ -51,6 +51,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ILOp.cs" />
|
<Compile Include="ILOp.cs" />
|
||||||
<Compile Include="ILOpCode.cs" />
|
<Compile Include="ILOpCode.cs" />
|
||||||
|
<Compile Include="ILOpCodes\InlineI.cs" />
|
||||||
<Compile Include="ILOpCodes\InlineNone.cs" />
|
<Compile Include="ILOpCodes\InlineNone.cs" />
|
||||||
<Compile Include="ILReader.cs" />
|
<Compile Include="ILReader.cs" />
|
||||||
<Compile Include="OpCodeAttribute.cs" />
|
<Compile Include="OpCodeAttribute.cs" />
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ namespace Cosmos.IL2CPU {
|
||||||
//TODO: Change this to an abstract class and make constructor protected
|
//TODO: Change this to an abstract class and make constructor protected
|
||||||
public class ILOpCode {
|
public class ILOpCode {
|
||||||
|
|
||||||
public readonly Code Value;
|
public readonly Code OpCode;
|
||||||
|
|
||||||
public ILOpCode(Code aValue) {
|
public ILOpCode(Code aOpCode) {
|
||||||
Value = aValue;
|
OpCode = aOpCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Use System.Reflection.Emit.OpCodes where possible, but we still need these
|
//TODO: Use System.Reflection.Emit.OpCodes where possible, but we still need these
|
||||||
|
|
|
||||||
15
source2/IL2PCU/Cosmos.IL2CPU/ILOpCodes/InlineI.cs
Normal file
15
source2/IL2PCU/Cosmos.IL2CPU/ILOpCodes/InlineI.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,8 @@ using System.Text;
|
||||||
namespace Cosmos.IL2CPU.ILOpCodes {
|
namespace Cosmos.IL2CPU.ILOpCodes {
|
||||||
public class InlineNone : ILOpCode {
|
public class InlineNone : ILOpCode {
|
||||||
|
|
||||||
public InlineNone(Code aValue) : base(aValue) {
|
public InlineNone(Code aOpCode)
|
||||||
|
: base(aOpCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ namespace Cosmos.IL2CPU {
|
||||||
// The operand is a 32-bit integer.
|
// The operand is a 32-bit integer.
|
||||||
case OperandType.InlineI:
|
case OperandType.InlineI:
|
||||||
xOperandSize = 4;
|
xOperandSize = 4;
|
||||||
xILOpCode = new ILOpCode(xOpCodeVal);
|
xILOpCode = new ILOpCodes.InlineI(xOpCodeVal, ReadInt32(xIL, 1));
|
||||||
break;
|
break;
|
||||||
// The operand is a 64-bit integer.
|
// The operand is a 64-bit integer.
|
||||||
case OperandType.InlineI8:
|
case OperandType.InlineI8:
|
||||||
|
|
@ -131,7 +131,7 @@ namespace Cosmos.IL2CPU {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OperandType.InlineSwitch: {
|
case OperandType.InlineSwitch: {
|
||||||
int xCount = ReadInt32(xIL, 1);
|
int xCount = (int)ReadInt32(xIL, 1);
|
||||||
int[] xBranchLocations = new int[xCount];
|
int[] xBranchLocations = new int[xCount];
|
||||||
uint[] xBranchValues = new uint[xCount];
|
uint[] xBranchValues = new uint[xCount];
|
||||||
for (int i = 0; i < xCount; i++) {
|
for (int i = 0; i < xCount; i++) {
|
||||||
|
|
@ -204,8 +204,8 @@ namespace Cosmos.IL2CPU {
|
||||||
return xResult;
|
return xResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Int32 ReadInt32(byte[] aBytes, int aPos) {
|
private UInt32 ReadInt32(byte[] aBytes, int aPos) {
|
||||||
return (aBytes[aPos + 3] << 24 | aBytes[aPos + 2] << 16 | aBytes[aPos + 1] << 8 | aBytes[aPos]);
|
return (UInt32)(aBytes[aPos + 3] << 24 | aBytes[aPos + 2] << 16 | aBytes[aPos + 1] << 8 | aBytes[aPos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//mOperandValueStr = mModule.ResolveString(OperandValueInt32);
|
//mOperandValueStr = mModule.ResolveString(OperandValueInt32);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue