mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 21:08:51 +00:00
28 lines
No EOL
717 B
C#
28 lines
No EOL
717 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Indy.IL2CPU.IL;
|
|
|
|
namespace Indy.IL2CPU {
|
|
public class OpCodeMap {
|
|
protected SortedList<byte, Op> mMap = new SortedList<byte, Op>();
|
|
|
|
public OpCodeMap() {
|
|
foreach (Type t in (from item in typeof(Op).Assembly.GetTypes()
|
|
where item.IsSubclassOf(typeof(Op))
|
|
select item)) {
|
|
Op op = Activator.CreateInstance(t) as Op;
|
|
mMap.Add(op.OpCode(), op);
|
|
}
|
|
}
|
|
|
|
public Op GetOpForOpCode(byte code)
|
|
{
|
|
if (!mMap.ContainsKey(code)) {
|
|
throw new NotSupportedException("OpCode '" + code.ToString("X2") + "' not supported!");
|
|
}
|
|
return mMap[code];
|
|
}
|
|
}
|
|
} |