Beispiel #1
0
 public OperationDescriptor(string name, string description, DynamicMethodDelegate @delegate, IEnumerable<ParameterDescriptor> parameters)
 {
   this.Name = name;
   this.Description = description;
   this.Parameters = Enumerable.ToArray<ParameterDescriptor>(parameters);
   this.Call = @delegate;
 }
Beispiel #2
0
 public PropertyDescriptor(string name, string description, Type type, DynamicMethodDelegate @delegate)
 {
   this.Name = name;
   this.Description = description;
   this.Type = type;
   this.GetValue = @delegate;
 }
Beispiel #3
0
 public EventDescriptor(string name, string description, DynamicMethodDelegate @delegate, DynamicMethodDelegate endTrigger)
 {
   this.Name = name;
   this.Description = description;
   this.AddHandler = @delegate;
   this.AddEndTriggerHandler = endTrigger;
 }
Beispiel #4
0
        //public DynamicMethodHandle( MethodInfo info, params object[] parameters )
        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicMethodHandle"/> class.
        /// </summary>
        /// <param name="info">MethodInfo</param>
        public DynamicMethodHandle( MethodInfo info )
        {
            if (info == null)
            {
                this.dynamicMethod = null;
            }
            else
            {
                this.methodName = info.Name;
                ParameterInfo[] infoParams = info.GetParameters();
                //object[] inParams = null;
                //if (parameters == null)
                //{
                //    inParams = new object[] { null };

                //}
                //else
                //{
                //    inParams = parameters;
                //}
                int pCount = infoParams.Length;
                if (pCount > 0 &&
                   ((pCount == 1 && infoParams[0].ParameterType.IsArray) ||
                   (infoParams[pCount - 1].GetCustomAttributes(typeof(ParamArrayAttribute), true).Length > 0)))
                {
                    this.hasFinalArrayParam = true;
                    this.methodParamsLength = pCount;
                    this.finalArrayElementType = infoParams[pCount - 1].ParameterType;
                }
                this.dynamicMethod = DynamicMethodHandlerFactory.CreateMethod(info);
            }

            this.parameterInfoList = info.GetParameters();
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MacroCode"/> class.
 /// </summary>
 /// <param name="Trigger">The trigger that run the method.</param>
 /// <param name="Method">The method to run.</param>
 /// <param name="Target">The target instance.</param>
 public MacroCode(GeneralTrigger Trigger, MethodInfo Method, object Target)
 {
     //set the target instance
     target = Target;
     //set the parameter count to zero since all user code triggers take zero args
     param = new object[0];
     trigger = Trigger;
     method = DynamicMethodDelegateFactory.Create(Method);
     this.IsSuspended = true;
 }
Beispiel #6
0
 public void Process()
 {
   EntityTypeDescriptor entityTypeDescriptor = EntityTypes.Types[this.Object.Type];
   OperationDescriptor operationDescriptor = entityTypeDescriptor.Operations[this.Operation];
   int num = entityTypeDescriptor.Static ? 0 : 1;
   this.ProcessedArguments = new object[num + operationDescriptor.Parameters.Length];
   if (!entityTypeDescriptor.Static)
     this.ProcessedArguments[0] = (object) this.Object.Identifier.Value;
   for (int index = 0; index < operationDescriptor.Parameters.Length; ++index)
   {
     ParameterDescriptor parameterDescriptor = operationDescriptor.Parameters[index];
     this.ProcessedArguments[num + index] = this.Arguments.Length > index ? Convert.ChangeType((object) this.Arguments[index], parameterDescriptor.Type, (IFormatProvider) CultureInfo.InvariantCulture) : (!(parameterDescriptor.Type == typeof (string)) ? Activator.CreateInstance(parameterDescriptor.Type) : (object) string.Empty);
   }
   this.Invoke = operationDescriptor.Call;
 }
Beispiel #7
0
        public DynamicMethodHandle(MethodInfo method)
        {
            if (method == null) throw new ArgumentNullException("info");

            this.Method = method;
            var parameters = method.GetParameters();
            this.MethodParamsLength = parameters.Length;

            if (MethodCaller.IsLastArray(parameters))
            {
                this.HasFinalArrayParam = true;
                this.FinalArrayElementType = parameters[parameters.Length - 1].ParameterType.GetElementType();
            }
            this.DynamicMethod = DynamicMethodHandlerFactory.CreateMethod(method);
        }
Beispiel #8
0
 public void Process()
 {
   EntityTypeDescriptor entityTypeDescriptor = EntityTypes.Types[this.Object.Type];
   PropertyDescriptor propertyDescriptor = entityTypeDescriptor.Properties[this.Property];
   this.processedValue = Convert.ChangeType((object) this.Value, propertyDescriptor.Type, (IFormatProvider) CultureInfo.InvariantCulture);
   this.GetValue = propertyDescriptor.GetValue;
   if (this.Operator != ComparisonOperator.Equal && this.Operator != ComparisonOperator.NotEqual)
     this.processedNumber = (float) this.processedValue;
   ScriptCondition scriptCondition = this;
   object[] objArray;
   if (!entityTypeDescriptor.Static)
     objArray = new object[1]
     {
       (object) this.Object.Identifier
     };
   else
     objArray = new object[0];
   scriptCondition.processedArguments = objArray;
 }
        static JSIMechJeb()
        {
            try
            {
                var loadedMechJebAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "MechJeb2");

                if (loadedMechJebAssy == null)
                {
                    mjFound = false;
                    //JUtil.LogMessage(this, "A supported version of MechJeb is {0}", (mjFound) ? "present" : "not available");

                    return;
                }

                //--- Process all the reflection info
                // MechJebCore
                mjMechJebCore_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebCore");
                if (mjMechJebCore_t == null)
                {
                    return;
                }
                MethodInfo mjGetComputerModule = mjMechJebCore_t.GetMethod("GetComputerModule", new Type[] { typeof(string) });
                if (mjGetComputerModule == null)
                {
                    throw new NotImplementedException("mjGetComputerModule");
                }
                getComputerModule = DynamicMethodDelegateFactory.Create(mjGetComputerModule);
                mjCoreTarget = mjMechJebCore_t.GetField("target", BindingFlags.Instance | BindingFlags.Public);
                if (mjCoreTarget == null)
                {
                    throw new NotImplementedException("mjCoreTarget");
                }
                mjCoreNode = mjMechJebCore_t.GetField("node", BindingFlags.Instance | BindingFlags.Public);
                if (mjCoreNode == null)
                {
                    throw new NotImplementedException("mjCoreNode");
                }
                mjCoreAttitude = mjMechJebCore_t.GetField("attitude", BindingFlags.Instance | BindingFlags.Public);
                if (mjCoreAttitude == null)
                {
                    throw new NotImplementedException("mjCoreAttitude");
                }
                mjCoreVesselState = mjMechJebCore_t.GetField("vesselState", BindingFlags.Instance | BindingFlags.Public);
                if (mjCoreVesselState == null)
                {
                    throw new NotImplementedException("mjCoreVesselState");
                }

                // VesselExtensions
                Type mjVesselExtensions_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.VesselExtensions");
                if (mjVesselExtensions_t == null)
                {
                    throw new NotImplementedException("mjVesselExtensions_t");
                }
                MethodInfo mjGetMasterMechJeb = mjVesselExtensions_t.GetMethod("GetMasterMechJeb", BindingFlags.Static | BindingFlags.Public);
                if (mjGetMasterMechJeb == null)
                {
                    throw new NotImplementedException("mjGetMasterMechJeb");
                }
                getMasterMechJeb = DynamicMethodDelegateFactory.Create(mjGetMasterMechJeb);
                MethodInfo mjPlaceManeuverNode = mjVesselExtensions_t.GetMethod("PlaceManeuverNode", BindingFlags.Static | BindingFlags.Public);
                if (mjPlaceManeuverNode == null)
                {
                    throw new NotImplementedException("mjPlaceManeuverNode");
                }
                placeManeuverNode = DynamicMethodDelegateFactory.Create(mjPlaceManeuverNode);

                // VesselState
                Type mjVesselState_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.VesselState");
                if (mjVesselState_t == null)
                {
                    throw new NotImplementedException("mjVesselState_t");
                }
                MethodInfo mjTerminalVelocity = mjVesselState_t.GetMethod("TerminalVelocity", BindingFlags.Instance | BindingFlags.Public);
                if (mjTerminalVelocity == null)
                {
                    throw new NotImplementedException("mjTerminalVelocity");
                }
                terminalVelocity = DynamicMethodDelegateFactory.CreateFuncDouble(mjTerminalVelocity);

                // SmartASS
                Type mjSmartass_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleSmartASS");
                mjSmartassTarget = mjSmartass_t.GetField("target", BindingFlags.Instance | BindingFlags.Public);
                if (mjSmartassTarget == null)
                {
                    throw new NotImplementedException("mjSmartassTarget");
                }
                MethodInfo mjSmartassEngage = mjSmartass_t.GetMethod("Engage", BindingFlags.Instance | BindingFlags.Public);
                if (mjSmartassEngage == null)
                {
                    throw new NotImplementedException("mjSmartassEngage");
                }
                engageSmartass = DynamicMethodDelegateFactory.Create(mjSmartassEngage);
                mjSmartassForceRol = mjSmartass_t.GetField("forceRol", BindingFlags.Instance | BindingFlags.Public);
                if (mjSmartassForceRol == null)
                {
                    throw new NotImplementedException("mjSmartassForceRol");
                }
                mjSmartassRol = mjSmartass_t.GetField("rol", BindingFlags.Instance | BindingFlags.Public);
                if (mjSmartassRol == null)
                {
                    throw new NotImplementedException("mjSmartassRol");
                }
                FieldInfo TargetTextsInfo = mjSmartass_t.GetField("TargetTexts", BindingFlags.Static | BindingFlags.Public);
                TargetTexts = (string[])TargetTextsInfo.GetValue(null);
                if (TargetTexts == null)
                {
                    throw new NotImplementedException("TargetTexts");
                }
                FieldInfo ModeTextsInfo = mjSmartass_t.GetField("ModeTexts", BindingFlags.Static | BindingFlags.Public);
                ModeTexts = (string[])ModeTextsInfo.GetValue(null);
                if (ModeTexts == null)
                {
                    throw new NotImplementedException("ModeTexts");
                }

                // Landing Predictions
                Type mjModuleLandingPredictions_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleLandingPredictions");
                if (mjModuleLandingPredictions_t == null)
                {
                    throw new NotImplementedException("mjModuleLandingPredictions_t");
                }
                MethodInfo mjPredictionsGetResult = mjModuleLandingPredictions_t.GetMethod("GetResult", BindingFlags.Instance | BindingFlags.Public);
                if (mjPredictionsGetResult == null)
                {
                    throw new NotImplementedException("mjPredictionsGetResult");
                }
                getPredictionsResult = DynamicMethodDelegateFactory.Create(mjPredictionsGetResult);

                // AbsoluteVector
                Type mjAbsoluteVector_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.AbsoluteVector");
                if (mjAbsoluteVector_t == null)
                {
                    throw new NotImplementedException("mjAbsoluteVector_t");
                }
                mjAbsoluteVectorLat = mjAbsoluteVector_t.GetField("latitude", BindingFlags.Instance | BindingFlags.Public);
                if (mjAbsoluteVectorLat == null)
                {
                    throw new NotImplementedException("mjAbsoluteVectorLat");
                }
                mjAbsoluteVectorLon = mjAbsoluteVector_t.GetField("longitude", BindingFlags.Instance | BindingFlags.Public);
                if (mjAbsoluteVectorLon == null)
                {
                    throw new NotImplementedException("mjAbsoluteVectorLon");
                }

                // MechJebModuleAscentAutopilot
                Type mjMechJebModuleAscentAutopilot_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleAscentAutopilot");
                if (mjMechJebModuleAscentAutopilot_t == null)
                {
                    throw new NotImplementedException("mjMechJebModuleAscentAutopilot_t");
                }
                launchOrbitAltitude = mjMechJebModuleAscentAutopilot_t.GetField("desiredOrbitAltitude");
                if (launchOrbitAltitude == null)
                {
                    throw new NotImplementedException("launchOrbitAltitude");
                }

                Type mjEditableDoubleMult_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.EditableDoubleMult");
                if (mjEditableDoubleMult_t == null)
                {
                    throw new NotImplementedException("mjEditableDoubleMult_t");
                }
                getEditableDoubleMultMultiplier = mjEditableDoubleMult_t.GetField("multiplier");
                if (getEditableDoubleMultMultiplier == null)
                {
                    throw new NotImplementedException("getEditableDoubleMultMultiplier");
                }
                PropertyInfo edmVal = mjEditableDoubleMult_t.GetProperty("val");
                if (edmVal == null)
                {
                    throw new NotImplementedException("edmVal");
                }
                // getEditableDoubleMult
                MethodInfo mjGetEDM = edmVal.GetGetMethod();
                if (mjGetEDM != null)
                {
                    getEditableDoubleMult = DynamicMethodDelegateFactory.CreateFuncDouble(mjGetEDM);
                }
                // setEditableDoubleMult
                MethodInfo mjSetEDM = edmVal.GetSetMethod();
                if (mjSetEDM != null)
                {
                    setEditableDoubleMult = DynamicMethodDelegateFactory.Create(mjSetEDM);
                }

                // EditableAngle
                Type mjEditableAngle_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.EditableAngle");
                if (mjEditableAngle_t == null)
                {
                    throw new NotImplementedException("mjEditableAngle_t");
                }
                MethodInfo mjAbsoluteVectorToDouble = null;
                foreach (MethodInfo method in mjEditableAngle_t.GetMethods(BindingFlags.Static | BindingFlags.Public))
                {
                    // The method name reports as "op_Implicit", but there are two
                    if (method.ReturnType == typeof(System.Double))
                    {
                        mjAbsoluteVectorToDouble = method;
                        break;
                    }
                }
                if (mjAbsoluteVectorToDouble == null)
                {
                    throw new NotImplementedException("mjAbsoluteVectorToDouble");
                }
                absoluteVectorToDouble = DynamicMethodDelegateFactory.Create(mjAbsoluteVectorToDouble);

                // MechJebModuleTargetController
                Type mjModuleTargetController_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleTargetController");
                if (mjModuleTargetController_t == null)
                {
                    throw new NotImplementedException("mjModuleTargetController_t");
                }
                mjTargetLongitude = mjModuleTargetController_t.GetField("targetLongitude", BindingFlags.Instance | BindingFlags.Public);
                if (mjTargetLongitude == null)
                {
                    throw new NotImplementedException("mjTargetLongitude");
                }
                mjTargetLatitude = mjModuleTargetController_t.GetField("targetLatitude", BindingFlags.Instance | BindingFlags.Public);
                if (mjTargetLatitude == null)
                {
                    throw new NotImplementedException("mjTargetLatitude");
                }
                PropertyInfo mjPositionTargetExists = mjModuleTargetController_t.GetProperty("PositionTargetExists", BindingFlags.Instance | BindingFlags.Public);
                MethodInfo mjGetPositionTargetExists = null;
                if (mjPositionTargetExists != null)
                {
                    mjGetPositionTargetExists = mjPositionTargetExists.GetGetMethod();
                }
                if (mjGetPositionTargetExists == null)
                {
                    throw new NotImplementedException("mjGetPositionTargetExists");
                }
                getPositionTargetExists = DynamicMethodDelegateFactory.CreateFuncBool(mjGetPositionTargetExists);
                PropertyInfo mjNormalTargetExists = mjModuleTargetController_t.GetProperty("NormalTargetExists", BindingFlags.Instance | BindingFlags.Public);
                MethodInfo mjGetNormalTargetExists = null;
                if (mjNormalTargetExists != null)
                {
                    mjGetNormalTargetExists = mjNormalTargetExists.GetGetMethod();
                }
                if (mjGetNormalTargetExists == null)
                {
                    throw new NotImplementedException("mjGetNormalTargetExists");
                }
                getNormalTargetExists = DynamicMethodDelegateFactory.CreateFuncBool(mjGetNormalTargetExists);
                PropertyInfo mjTargetOrbit = mjModuleTargetController_t.GetProperty("TargetOrbit", BindingFlags.Instance | BindingFlags.Public); ;
                MethodInfo mjGetTargetOrbit = null;
                if (mjTargetOrbit != null)
                {
                    mjGetTargetOrbit = mjTargetOrbit.GetGetMethod();
                }
                if (mjGetTargetOrbit == null)
                {
                    throw new NotImplementedException("mjGetTargetOrbit");
                }
                getTargetOrbit = DynamicMethodDelegateFactory.CreateFuncObject(mjGetTargetOrbit);

                // MuMech.FuelFlowSimulation
                Type mjFuelFlowSimulation_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.FuelFlowSimulation");
                if (mjFuelFlowSimulation_t == null)
                {
                    throw new NotImplementedException("mjFuelFlowSimulation_t");
                }
                // MuMech.FuelFlowSimulation.Stats
                Type mjFuelFlowSimulationStats_t = mjFuelFlowSimulation_t.GetNestedType("Stats");
                if (mjFuelFlowSimulationStats_t == null)
                {
                    throw new NotImplementedException("mjFuelFlowSimulationStats_t");
                }
                mjStageDv = mjFuelFlowSimulationStats_t.GetField("deltaV", BindingFlags.Instance | BindingFlags.Public);
                if (mjStageDv == null)
                {
                    throw new NotImplementedException("mjStageDv");
                }

                // MuMech.ReentrySimulation.Result
                Type mjReentrySim_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.ReentrySimulation");
                if (mjReentrySim_t == null)
                {
                    throw new NotImplementedException("mjReentrySim_t");
                }
                Type mjReentryResult_t = mjReentrySim_t.GetNestedType("Result");
                if (mjReentryResult_t == null)
                {
                    throw new NotImplementedException("mjReentryResult_t");
                }
                mjReentryOutcome = mjReentryResult_t.GetField("outcome", BindingFlags.Instance | BindingFlags.Public);
                if (mjReentryOutcome == null)
                {
                    throw new NotImplementedException("mjReentryOutcome");
                }
                mjReentryEndPosition = mjReentryResult_t.GetField("endPosition", BindingFlags.Instance | BindingFlags.Public);
                if (mjReentryEndPosition == null)
                {
                    throw new NotImplementedException("mjReentryEndPosition");
                }
                mjReentryTime = mjReentryResult_t.GetField("endUT", BindingFlags.Instance | BindingFlags.Public);
                if (mjReentryTime == null)
                {
                    throw new NotImplementedException("mjReentryTime");
                }

                // UserPool
                Type mjUserPool_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.UserPool");
                MethodInfo mjAddUser = mjUserPool_t.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public);
                if (mjAddUser == null)
                {
                    throw new NotImplementedException("mjAddUser");
                }
                addUser = DynamicMethodDelegateFactory.Create(mjAddUser);
                MethodInfo mjRemoveUser = mjUserPool_t.GetMethod("Remove", BindingFlags.Instance | BindingFlags.Public);
                if (mjRemoveUser == null)
                {
                    throw new NotImplementedException("mjRemoveUser");
                }
                removeUser = DynamicMethodDelegateFactory.Create(mjRemoveUser);
                MethodInfo mjContainsUser = mjUserPool_t.GetMethod("Contains", BindingFlags.Instance | BindingFlags.Public);
                if (mjContainsUser == null)
                {
                    throw new NotImplementedException("mjContainsUser");
                }
                containsUser = DynamicMethodDelegateFactory.Create(mjContainsUser);

                // MechJebModuleLandingAutopilot
                Type mjLandingAutopilot_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleLandingAutopilot");
                MethodInfo mjLandAtPositionTarget = mjLandingAutopilot_t.GetMethod("LandAtPositionTarget", BindingFlags.Instance | BindingFlags.Public);
                if (mjLandAtPositionTarget == null)
                {
                    throw new NotImplementedException("mjLandAtPositionTarget");
                }
                landAtPositionTarget = DynamicMethodDelegateFactory.Create(mjLandAtPositionTarget);
                MethodInfo mjLandUntargeted = mjLandingAutopilot_t.GetMethod("LandUntargeted", BindingFlags.Instance | BindingFlags.Public);
                if (mjLandUntargeted == null)
                {
                    throw new NotImplementedException("mjLandUntargeted");
                }
                landUntargeted = DynamicMethodDelegateFactory.Create(mjLandUntargeted);
                MethodInfo mjStopLanding = mjLandingAutopilot_t.GetMethod("StopLanding", BindingFlags.Instance | BindingFlags.Public);
                if (mjStopLanding == null)
                {
                    throw new NotImplementedException("mjStopLanding");
                }
                stopLanding = DynamicMethodDelegateFactory.CreateAction(mjStopLanding);

                Type mjSpaceplaneAutopilot_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleSpaceplaneAutopilot");
                MethodInfo mjSPAutoland = mjSpaceplaneAutopilot_t.GetMethod("Autoland", BindingFlags.Instance | BindingFlags.Public);
                if (mjSPAutoland == null)
                {
                    throw new NotImplementedException("mjSPAutoland");
                }
                spaceplaneAutoland = DynamicMethodDelegateFactory.Create(mjSPAutoland);
                MethodInfo mjSPHoldHeadingAndAltitude = mjSpaceplaneAutopilot_t.GetMethod("HoldHeadingAndAltitude", BindingFlags.Instance | BindingFlags.Public);
                if (mjSPHoldHeadingAndAltitude == null)
                {
                    throw new NotImplementedException("mjSPHoldHeadingAndAltitude");
                }
                spaceplaneHoldHeading = DynamicMethodDelegateFactory.Create(mjSPHoldHeadingAndAltitude);
                MethodInfo mjSPAutopilotOff = mjSpaceplaneAutopilot_t.GetMethod("AutopilotOff", BindingFlags.Instance | BindingFlags.Public);
                if (mjSPAutopilotOff == null)
                {
                    throw new NotImplementedException("mjSPAutopilotOff");
                }
                spaceplaneAPOff = DynamicMethodDelegateFactory.CreateAction(mjSPAutopilotOff);
                spaceplaneAPMode = mjSpaceplaneAutopilot_t.GetField("mode", BindingFlags.Instance | BindingFlags.Public);
                if (spaceplaneAPMode == null)
                {
                    throw new NotImplementedException("spaceplaneAPMode");
                }
                spaceplaneAltitude = mjSpaceplaneAutopilot_t.GetField("targetAltitude", BindingFlags.Instance | BindingFlags.Public);
                if (spaceplaneAltitude == null)
                {
                    throw new NotImplementedException("spaceplaneAltitude");
                }
                spaceplaneHeading = mjSpaceplaneAutopilot_t.GetField("targetHeading", BindingFlags.Instance | BindingFlags.Public);
                if (spaceplaneHeading == null)
                {
                    throw new NotImplementedException("spaceplaneHeading");
                }
                spaceplaneGlideslope = mjSpaceplaneAutopilot_t.GetField("glideslope", BindingFlags.Instance | BindingFlags.Public);
                if (spaceplaneGlideslope == null)
                {
                    throw new NotImplementedException("spaceplaneGlideslope");
                }

                // EditableDouble
                Type mjEditableDouble_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.EditableDouble");
                PropertyInfo mjEditableDoubleVal = mjEditableDouble_t.GetProperty("val", BindingFlags.Instance | BindingFlags.Public);
                MethodInfo mjGetEditableDouble = null, mjSetEditableDouble = null;
                if (mjEditableDoubleVal != null)
                {
                    mjGetEditableDouble = mjEditableDoubleVal.GetGetMethod();
                    mjSetEditableDouble = mjEditableDoubleVal.GetSetMethod();
                }
                if (mjGetEditableDouble == null)
                {
                    throw new NotImplementedException("mjGetEditableDouble");
                }
                getEditableDouble = DynamicMethodDelegateFactory.CreateFuncDouble(mjGetEditableDouble);
                if (mjSetEditableDouble == null)
                {
                    throw new NotImplementedException("mjSetEditableDouble");
                }
                setEditableDouble = DynamicMethodDelegateFactory.Create(mjSetEditableDouble);

                // OrbitalManeuverCalculator
                Type mjOrbitalManeuverCalculator_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.OrbitalManeuverCalculator");
                mjDeltaVAndTimeForHohmannTransfer = mjOrbitalManeuverCalculator_t.GetMethod("DeltaVAndTimeForHohmannTransfer", BindingFlags.Static | BindingFlags.Public);
                if (mjDeltaVAndTimeForHohmannTransfer == null)
                {
                    throw new NotImplementedException("mjDeltaVAndTimeForHohmannTransfer");
                }
                //deltaVAndTimeForHohmannTransfer = DynamicMethodDelegateFactory.Create(mjDeltaVAndTimeForHohmannTransfer);
                mjDeltaVAndTimeForInterplanetaryTransferEjection = mjOrbitalManeuverCalculator_t.GetMethod("DeltaVAndTimeForInterplanetaryTransferEjection", BindingFlags.Static | BindingFlags.Public);
                if (mjDeltaVAndTimeForInterplanetaryTransferEjection == null)
                {
                    throw new NotImplementedException("mjDeltaVAndTimeForInterplanetaryTransferEjection");
                }
                //deltaVAndTimeForInterplanetaryTransferEjection = DynamicMethodDelegateFactory.Create(mjDeltaVAndTimeForInterplanetaryTransferEjection);
                MethodInfo mjDeltaVToCircularize = mjOrbitalManeuverCalculator_t.GetMethod("DeltaVToCircularize", BindingFlags.Static | BindingFlags.Public);
                if (mjDeltaVToCircularize == null)
                {
                    throw new NotImplementedException("mjDeltaVToCircularize");
                }
                deltaVToCircularize = DynamicMethodDelegateFactory.Create(mjDeltaVToCircularize);

                // MechJebModuleStageStats
                Type mjModuleStageStats_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleStageStats");
                if (mjModuleStageStats_t == null)
                {
                    throw new NotImplementedException("mjModuleStageStats_t");
                }
                MethodInfo mjRequestUpdate = mjModuleStageStats_t.GetMethod("RequestUpdate", BindingFlags.Instance | BindingFlags.Public);
                if (mjRequestUpdate == null)
                {
                    throw new NotImplementedException("mjRequestUpdate");
                }
                requestUpdate = DynamicMethodDelegateFactory.Create(mjRequestUpdate);
                mjVacStageStats = mjModuleStageStats_t.GetField("vacStats", BindingFlags.Instance | BindingFlags.Public);
                if (mjVacStageStats == null)
                {
                    throw new NotImplementedException("mjVacStageStats");
                }

                // Updated MechJeb (post 2.5.1) switched from using KER back to
                // its internal FuelFlowSimulation.  This sim uses an array of
                // structs, which entails a couple of extra hoops to jump through
                // when reading via reflection.
                mjAtmStageStats = mjModuleStageStats_t.GetField("atmoStats", BindingFlags.Instance | BindingFlags.Public);
                if (mjAtmStageStats == null)
                {
                    throw new NotImplementedException("mjAtmStageStats");
                }

                PropertyInfo mjStageStatsLength = mjVacStageStats.FieldType.GetProperty("Length");
                if (mjStageStatsLength == null)
                {
                    throw new NotImplementedException("mjStageStatsLength");
                }
                MethodInfo mjStageStatsGetLength = mjStageStatsLength.GetGetMethod();
                if (mjStageStatsGetLength == null)
                {
                    throw new NotImplementedException("mjStageStatsGetLength");
                }
                stageStatsGetLength = DynamicMethodDelegateFactory.CreateFuncInt(mjStageStatsGetLength);
                MethodInfo mjStageStatsGetIndex = mjVacStageStats.FieldType.GetMethod("Get");
                if (mjStageStatsGetIndex == null)
                {
                    throw new NotImplementedException("mjStageStatsGetIndex");
                }
                stageStatsGetIndex = DynamicMethodDelegateFactory.Create(mjStageStatsGetIndex);

                // MechJebModuleNodeExecutor
                Type mjNodeExecutor_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleNodeExecutor");
                MethodInfo mjExecuteOneNode = mjNodeExecutor_t.GetMethod("ExecuteOneNode", BindingFlags.Instance | BindingFlags.Public);
                if (mjExecuteOneNode == null)
                {
                    throw new NotImplementedException("mjExecuteOneNode");
                }
                executeOneNode = DynamicMethodDelegateFactory.Create(mjExecuteOneNode);
                MethodInfo mjAbortNode = mjNodeExecutor_t.GetMethod("Abort", BindingFlags.Instance | BindingFlags.Public);
                if (mjAbortNode == null)
                {
                    throw new NotImplementedException("mjAbortNode");
                }
                abortNode = DynamicMethodDelegateFactory.CreateAction(mjAbortNode);

                // Computer Module
                Type mjComputerModule_t = loadedMechJebAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "MuMech.ComputerModule");
                PropertyInfo mjModuleEnabledProperty = mjComputerModule_t.GetProperty("enabled", BindingFlags.Instance | BindingFlags.Public);
                MethodInfo mjModuleEnabled = null;
                if (mjModuleEnabledProperty != null)
                {
                    mjModuleEnabled = mjModuleEnabledProperty.GetGetMethod();
                }
                if (mjModuleEnabled == null)
                {
                    throw new NotImplementedException("mjModuleEnabled");
                }
                moduleEnabled = DynamicMethodDelegateFactory.CreateFuncBool(mjModuleEnabled);
                mjModuleUsers = mjComputerModule_t.GetField("users", BindingFlags.Instance | BindingFlags.Public);
                if (mjModuleUsers == null)
                {
                    throw new NotImplementedException("mjModuleUsers");
                }
            }
            catch (Exception e)
            {
                mjMechJebCore_t = null;
                JUtil.LogMessage(null, "Exception initializing JSIMechJeb: {0}", e);
            }

            if (mjMechJebCore_t != null && getMasterMechJeb != null)
            {
                mjFound = true;
            }
            else
            {
                mjFound = false;
            }
        }
        static JSIPilotAssistant()
        {
            try
            {
                var loadedPAAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "PilotAssistant");
                if (loadedPAAssy == null)
                {
                    //JUtil.LogMessage(null, "Did not load PilotAssistant");
                    //var list = AssemblyLoader.loadedAssemblies;
                    //foreach(var a in list)
                    //{
                    //    JUtil.LogMessage(null, "-- {0}", a.name);
                    //}
                    return;
                }
                //else
                //{
                //    JUtil.LogMessage(null, "Did find PilotAssistant");
                //}

                Type paAsstVesselModule_t = loadedPAAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "PilotAssistant.FlightModules.AsstVesselModule");
                if (paAsstVesselModule_t == null)
                {
                    throw new NotImplementedException("paAsstVesselModule_t");
                }

                vesselAsst_t = paAsstVesselModule_t.GetField("vesselAsst", BindingFlags.Instance | BindingFlags.Public);
                if (vesselAsst_t == null)
                {
                    throw new NotImplementedException("vesselAsst_t");
                }

                Type paPilotAssistant_t = loadedPAAssy.assembly.GetExportedTypes()
                    .SingleOrDefault(t => t.FullName == "PilotAssistant.FlightModules.PilotAssistant");
                if (paPilotAssistant_t == null)
                {
                    throw new NotImplementedException("paPilotAssistant_t");
                }

                vertMode_t = paPilotAssistant_t.GetField("CurrentVertMode", BindingFlags.Instance | BindingFlags.Public);
                if (vertMode_t == null)
                {
                    throw new NotImplementedException("currentVertMode_t");
                }
                vertActive_t = paPilotAssistant_t.GetField("VertActive", BindingFlags.Instance | BindingFlags.Public);
                if (vertActive_t == null)
                {
                    throw new NotImplementedException("vertActive_t");
                }
                MethodInfo vertSetting_t = paPilotAssistant_t.GetMethod("GetCurrentVert", BindingFlags.Instance | BindingFlags.Public);
                if (vertSetting_t == null)
                {
                    throw new NotImplementedException("vertSetting_t");
                }
                GetCurrentVert = DynamicMethodDelegateFactory.CreateFuncDouble(vertSetting_t);
                MethodInfo setVert_t = paPilotAssistant_t.GetMethod("SetVert", BindingFlags.Instance | BindingFlags.Public);
                if (setVert_t == null)
                {
                    throw new NotImplementedException("setVert_t");
                }
                SetVert = DynamicMethodDelegateFactory.Create(setVert_t);

                horzMode_t = paPilotAssistant_t.GetField("CurrentHrztMode", BindingFlags.Instance | BindingFlags.Public);
                if (horzMode_t == null)
                {
                    throw new NotImplementedException("horzMode_t");
                }
                horzActive_t = paPilotAssistant_t.GetField("HrztActive", BindingFlags.Instance | BindingFlags.Public);
                if (horzActive_t == null)
                {
                    throw new NotImplementedException("horzActive_t");
                }
                MethodInfo horzSetting_t = paPilotAssistant_t.GetMethod("GetCurrentHrzt", BindingFlags.Instance | BindingFlags.Public);
                if (horzSetting_t == null)
                {
                    throw new NotImplementedException("horzSetting_t");
                }
                GetCurrentHorz = DynamicMethodDelegateFactory.CreateFuncDouble(horzSetting_t);
                MethodInfo setHorz_t = paPilotAssistant_t.GetMethod("SetHrzt", BindingFlags.Instance | BindingFlags.Public);
                if (setHorz_t == null)
                {
                    throw new NotImplementedException("setHorz_t");
                }
                SetHorz = DynamicMethodDelegateFactory.Create(setHorz_t);

                throttleMode_t = paPilotAssistant_t.GetField("CurrentThrottleMode", BindingFlags.Instance | BindingFlags.Public);
                if (throttleMode_t == null)
                {
                    throw new NotImplementedException("throttleMode_t");
                }
                throttleActive_t = paPilotAssistant_t.GetField("ThrtActive", BindingFlags.Instance | BindingFlags.Public);
                if (throttleActive_t == null)
                {
                    throw new NotImplementedException("throttleActive_t");
                }
                MethodInfo throttleSetting_t = paPilotAssistant_t.GetMethod("GetCurrentThrottle", BindingFlags.Instance | BindingFlags.Public);
                if (throttleSetting_t == null)
                {
                    throw new NotImplementedException("throttleSetting_t");
                }
                GetCurrentThrottle = DynamicMethodDelegateFactory.CreateFuncDouble(throttleSetting_t);
                MethodInfo setThrottle_t = paPilotAssistant_t.GetMethod("SetThrottle", BindingFlags.Instance | BindingFlags.Public);
                if (setThrottle_t == null)
                {
                    throw new NotImplementedException("setThrottle_t");
                }
                SetThrottle = DynamicMethodDelegateFactory.Create(setThrottle_t);

                speedRef_t = paPilotAssistant_t.GetField("speedRef", BindingFlags.Instance | BindingFlags.NonPublic);
                if (speedRef_t == null)
                {
                    throw new NotImplementedException("PA speedRef_t");
                }
                MethodInfo changeSpeedRef_t = paPilotAssistant_t.GetMethod("ChangeSpeedRef", BindingFlags.Instance | BindingFlags.Public);
                if (changeSpeedRef_t == null)
                {
                    throw new NotImplementedException("PA changeSpeedRef_t");
                }
                SetSpeedRef = DynamicMethodDelegateFactory.Create(changeSpeedRef_t);

                speedUnits_t = paPilotAssistant_t.GetField("units", BindingFlags.Instance | BindingFlags.NonPublic);
                if (speedUnits_t == null)
                {
                    throw new NotImplementedException("PA speedUnits_t");
                }
                MethodInfo changeSpeedUnits_t = paPilotAssistant_t.GetMethod("ChangeSpeedUnit", BindingFlags.Instance | BindingFlags.Public);
                if (changeSpeedUnits_t == null)
                {
                    throw new NotImplementedException("PA changeSpeedUnits_t");
                }
                SetSpeedUnits = DynamicMethodDelegateFactory.Create(changeSpeedUnits_t);

                pauseState_t = paPilotAssistant_t.GetField("bPause", BindingFlags.Instance | BindingFlags.Public);
                if (pauseState_t == null)
                {
                    throw new NotImplementedException("PA pauseState_t");
                }
                MethodInfo TogglePause_t = paPilotAssistant_t.GetMethod("TogglePauseCtrlState", BindingFlags.Instance | BindingFlags.Public);
                if (TogglePause_t == null)
                {
                    throw new NotImplementedException("PA TogglePause_t");
                }
                TogglePause = DynamicMethodDelegateFactory.CreateAction(TogglePause_t);
            }
            catch (Exception e)
            {
                JUtil.LogMessage(null, "Exception tripped: {0}", e);
                paFound = false;
                return;
            }

            paFound = true;
        }
Beispiel #11
0
        static JSIPilotAssistant()
        {
            try
            {
                var loadedPAAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "PilotAssistant");
                if (loadedPAAssy == null)
                {
                    //JUtil.LogMessage(null, "Did not load PilotAssistant");
                    //var list = AssemblyLoader.loadedAssemblies;
                    //foreach(var a in list)
                    //{
                    //    JUtil.LogMessage(null, "-- {0}", a.name);
                    //}
                    return;
                }
                //else
                //{
                //    JUtil.LogMessage(null, "Did find PilotAssistant");
                //}

                Type paAsstVesselModule_t = loadedPAAssy.assembly.GetExportedTypes()
                                            .SingleOrDefault(t => t.FullName == "PilotAssistant.FlightModules.AsstVesselModule");
                if (paAsstVesselModule_t == null)
                {
                    throw new NotImplementedException("paAsstVesselModule_t");
                }

                vesselAsst_t = paAsstVesselModule_t.GetField("vesselAsst", BindingFlags.Instance | BindingFlags.Public);
                if (vesselAsst_t == null)
                {
                    throw new NotImplementedException("vesselAsst_t");
                }

                Type paPilotAssistant_t = loadedPAAssy.assembly.GetExportedTypes()
                                          .SingleOrDefault(t => t.FullName == "PilotAssistant.FlightModules.PilotAssistant");
                if (paPilotAssistant_t == null)
                {
                    throw new NotImplementedException("paPilotAssistant_t");
                }

                vertMode_t = paPilotAssistant_t.GetField("CurrentVertMode", BindingFlags.Instance | BindingFlags.Public);
                if (vertMode_t == null)
                {
                    throw new NotImplementedException("currentVertMode_t");
                }
                vertActive_t = paPilotAssistant_t.GetField("VertActive", BindingFlags.Instance | BindingFlags.Public);
                if (vertActive_t == null)
                {
                    throw new NotImplementedException("vertActive_t");
                }
                MethodInfo vertSetting_t = paPilotAssistant_t.GetMethod("GetCurrentVert", BindingFlags.Instance | BindingFlags.Public);
                if (vertSetting_t == null)
                {
                    throw new NotImplementedException("vertSetting_t");
                }
                GetCurrentVert = DynamicMethodDelegateFactory.CreateFuncDouble(vertSetting_t);
                MethodInfo setVert_t = paPilotAssistant_t.GetMethod("SetVert", BindingFlags.Instance | BindingFlags.Public);
                if (setVert_t == null)
                {
                    throw new NotImplementedException("setVert_t");
                }
                SetVert = DynamicMethodDelegateFactory.Create(setVert_t);

                horzMode_t = paPilotAssistant_t.GetField("CurrentHrztMode", BindingFlags.Instance | BindingFlags.Public);
                if (horzMode_t == null)
                {
                    throw new NotImplementedException("horzMode_t");
                }
                horzActive_t = paPilotAssistant_t.GetField("HrztActive", BindingFlags.Instance | BindingFlags.Public);
                if (horzActive_t == null)
                {
                    throw new NotImplementedException("horzActive_t");
                }
                MethodInfo horzSetting_t = paPilotAssistant_t.GetMethod("GetCurrentHrzt", BindingFlags.Instance | BindingFlags.Public);
                if (horzSetting_t == null)
                {
                    throw new NotImplementedException("horzSetting_t");
                }
                GetCurrentHorz = DynamicMethodDelegateFactory.CreateFuncDouble(horzSetting_t);
                MethodInfo setHorz_t = paPilotAssistant_t.GetMethod("SetHrzt", BindingFlags.Instance | BindingFlags.Public);
                if (setHorz_t == null)
                {
                    throw new NotImplementedException("setHorz_t");
                }
                SetHorz = DynamicMethodDelegateFactory.Create(setHorz_t);

                throttleMode_t = paPilotAssistant_t.GetField("CurrentThrottleMode", BindingFlags.Instance | BindingFlags.Public);
                if (throttleMode_t == null)
                {
                    throw new NotImplementedException("throttleMode_t");
                }
                throttleActive_t = paPilotAssistant_t.GetField("ThrtActive", BindingFlags.Instance | BindingFlags.Public);
                if (throttleActive_t == null)
                {
                    throw new NotImplementedException("throttleActive_t");
                }
                MethodInfo throttleSetting_t = paPilotAssistant_t.GetMethod("GetCurrentThrottle", BindingFlags.Instance | BindingFlags.Public);
                if (throttleSetting_t == null)
                {
                    throw new NotImplementedException("throttleSetting_t");
                }
                GetCurrentThrottle = DynamicMethodDelegateFactory.CreateFuncDouble(throttleSetting_t);
                MethodInfo setThrottle_t = paPilotAssistant_t.GetMethod("SetThrottle", BindingFlags.Instance | BindingFlags.Public);
                if (setThrottle_t == null)
                {
                    throw new NotImplementedException("setThrottle_t");
                }
                SetThrottle = DynamicMethodDelegateFactory.Create(setThrottle_t);
            }
            catch (Exception e)
            {
                JUtil.LogMessage(null, "Exception tripped: {0}", e);
                paFound = false;
                return;
            }

            paFound = true;
        }
Beispiel #12
0
 private DynamicMethodClass(DynamicMethodDelegate method)
 {
     CallMethod = method;
 }
Beispiel #13
0
        public static bool TestReflectionHelperTime()
        {
            object[] args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
            Console.WriteLine($"Initial args: {args[0]} {args[1]} {args[2]} {(args[3] == null ? "null" : args[3])} {args[4]}");

            MethodInfo method = typeof(QuickDebugTest).GetMethod("TestA");

            const long runs = 1000000000;

            Console.WriteLine("Test-running Stopwatch");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            sw.Stop();
            TimeSpan timeNewBox  = sw.Elapsed;
            TimeSpan timeLocals  = sw.Elapsed;
            TimeSpan timeMutable = sw.Elapsed;
            TimeSpan timeJmp     = sw.Elapsed;

            sw.Reset();

            Console.WriteLine("Generating local-less delegate");
            DynamicMethodDelegate dmdNewBox = method.CreateDelegate(directBoxValueAccess: false);

            Console.WriteLine("Test-running dmdNewBox");
            args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
            dmdNewBox(null, args);
            if (!(
                    (int)args[0] == 1 &&
                    (int)args[1] == 1 &&
                    (int)args[2] == 2 &&
                    ((QuickDebugTestObject)args[3])?.Value == 1 &&
                    ((QuickDebugTestStruct)args[4]).Value == 1
                    ))
            {
                return(false);
            }
            args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };

            Console.WriteLine($"Timing dmdNewBox {runs} runs");
            sw.Start();
            for (long i = runs; i > -1; --i)
            {
                dmdNewBox(null, args);
            }
            sw.Stop();
            args       = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
            timeNewBox = sw.Elapsed;
            sw.Reset();
            Console.WriteLine($"time: {timeNewBox}");


            Console.WriteLine("Generating mutability-ignoring delegate");
            DynamicMethodDelegate dmdMutable = method.CreateDelegate(directBoxValueAccess: true);

            Console.WriteLine("Test-running dmdMutable");
            args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
            dmdMutable(null, args);
            if (!(
                    (int)args[0] == 1 &&
                    (int)args[1] == 1 &&
                    (int)args[2] == 2 &&
                    ((QuickDebugTestObject)args[3])?.Value == 1 &&
                    ((QuickDebugTestStruct)args[4]).Value == 1
                    ))
            {
                return(false);
            }
            args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };

            Console.WriteLine($"Timing dmdMutable {runs} runs");
            sw.Start();
            for (long i = runs; i > -1; --i)
            {
                dmdMutable(null, args);
            }
            sw.Stop();
            args        = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
            timeMutable = sw.Elapsed;
            sw.Reset();
            Console.WriteLine($"time: {timeMutable}");

            /*
             * Console.WriteLine("Generating localed delegate");
             * DynamicMethodDelegate dmdLocals = method.CreateDelegateUsingLocals();
             * Console.WriteLine("Test-running dmdLocals");
             * args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
             * dmdLocals(null, args);
             * if (!(
             *  (int) args[0] == 1 &&
             *  (int) args[1] == 1 &&
             *  (int) args[2] == 2 &&
             *  ((QuickDebugTestObject) args[3])?.Value == 1 &&
             *  ((QuickDebugTestStruct) args[4]).Value == 1
             *  )) return false;
             * args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
             *
             * Console.WriteLine($"Timing dmdLocals {runs} runs");
             * sw.Start();
             * for (long i = runs; i > -1; --i) {
             *  dmdLocals(null, args);
             * }
             * sw.Stop();
             * args = new object[] { 1, 0, 0, null, new QuickDebugTestStruct() };
             * timeLocals = sw.Elapsed;
             * sw.Reset();
             * Console.WriteLine($"time: {timeLocals}");
             */

            Console.WriteLine("Generating jmp delegate");
            d_TestA dmdJmp = method.CreateJmpDelegate <d_TestA>();

            Console.WriteLine("Test-running dmdJmp");
            int a = 1;
            int b = 0;
            int c = 0;
            QuickDebugTestObject d = null;
            QuickDebugTestStruct e = new QuickDebugTestStruct();

            dmdJmp(a, ref b, out c, out d, ref e);
            if (!(
                    a == 1 &&
                    b == 1 &&
                    c == 2 &&
                    d?.Value == 1 &&
                    e.Value == 1
                    ))
            {
                return(false);
            }

            Console.WriteLine($"Timing dmdJmp {runs} runs");
            sw.Start();
            for (long i = runs; i > -1; --i)
            {
                dmdJmp(a, ref b, out c, out d, ref e);
            }
            sw.Stop();
            timeJmp = sw.Elapsed;
            sw.Reset();
            Console.WriteLine($"time: {timeJmp}");


            Console.WriteLine($"newbox / jmp: {(double) timeNewBox.Ticks / (double) timeJmp.Ticks}");
            Console.WriteLine($"jmp / newbox: {(double) timeJmp.Ticks / (double) timeNewBox.Ticks}");

            Console.WriteLine($"newbox / mutable: {(double) timeNewBox.Ticks / (double) timeMutable.Ticks}");
            Console.WriteLine($"mutable / newbox: {(double) timeMutable.Ticks / (double) timeNewBox.Ticks}");

            Console.WriteLine($"jmp / mutable: {(double) timeJmp.Ticks / (double) timeMutable.Ticks}");
            Console.WriteLine($"mutable / jmp: {(double) timeMutable.Ticks / (double) timeJmp.Ticks}");

            Console.WriteLine("Pass");
            return(true);
        }