예제 #1
0
        private void CompileAndGetIL(string sourceCode)
        {
            SetDescription("Compiling code...");

            _compilationTask = Task.Factory.StartNew(() =>
            {
                try
                {
                    var compiledMethod = Compiler.Compile(sourceCode);

                    var methodIL = ILTools.GetMethodIL(compiledMethod.Method);

                    ilList.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        ilList.Items.Clear();
                        foreach (var ilInstruction in methodIL.Instructions)
                        {
                            ilList.Items.Add(ilInstruction);
                        }

                        SetDescription("Press F5 to compile");
                    }), null);
                }
                catch (Exception ex)
                {
                    SetDescription("Press F5 to compile");
                    MessageBox.Show("Could not compile.\r\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            });
        }
 public static MethodILInfo GetInstructions(this MethodInfo methodInfo)
 {
     return(ILTools.GetMethodIL(methodInfo));
 }