Debugger.MethodManager

Overview

It provides the function delegate from reflection with a given function name. It currently has six different delegate types based on the instruction specification.

        public delegate void OneRegister(Register rX);
        public delegate void TwoRegister(Register rX, Register rY);
        public delegate void ThreeRegister(Register rX, Register rY, Register rZ);
        public delegate void OneRgisterOneNumber(Register rX, short n);
        public delegate void NoRegister();
        public delegate void OneNumber(short n);

How it works

It uses reflection to match function signature with given name.

This is code sample in constructor.
       var methodInfo = typeof(Methods).GetMethod(methodName);
       int argCount = methodInfo.GetParameters().Length;
       Delegate method = null;
       if(argCount == 3)
       {
           method = Delegate.CreateDelegate(typeof(ThreeRegister), methodInfo);
        }
        // etc

Usage

After instantiate the MethodManager, you can access a function by following code.
       var manager = MethodManager();
       Delegate delegate = manager.GetMehod("nop"); // for example, nop

Last edited Apr 3, 2014 at 2:23 AM by Kuree, version 1