Пример #1
0
        //private void ThreadRunInConsole(object data)
        //{
        //    try
        //    {
        //        Tuple<Parser, Assembly> myData = data as Tuple<Parser, Assembly>;
        //        myData.Item1.Execute(myData.Item2, _consoleWriter);
        //    }
        //    catch
        //    {
        //    }
        //}
        public void RunInConsole(object parameter)
        {
            _window.ConsoleTab.IsSelected = true;
            _consoleWriter.Reset();
            Parser parser = new Parser();
            try
            {
                Assembly asm = parser.CompileForRun(Code);
                parser.Execute(asm, _consoleWriter);

                //Tuple<Parser, Assembly> myData = new Tuple<Parser, Assembly>(parser, asm);
                //Thread newThread = new Thread(this.ThreadRunInConsole);
                //newThread.IsBackground = true;
                //newThread.Start(myData);
            }
            catch (Exception e)
            {
                PrintException(e);
            }
        }
Пример #2
0
        public void GenerateFromCode(object parameter)
        {
            _window.CircuitTab.IsSelected = true;

            string code = Code;
            if (string.IsNullOrWhiteSpace(code))
            {
                return;
            }

            Parser parser = new Parser();

            try
            {
                Assembly asmToBuild = parser.CompileForBuild(code);
                CircuitEvaluator eval = CircuitEvaluator.GetInstance();

                Dictionary<string, List<MethodCode>> methods = parser.GetMethodsCodes(code);
                if (methods.Count > 0)
                {
                    Assembly asmToRun = parser.CompileForRun(code);
                    eval.LoadLibMethods(asmToRun);
                    eval.LoadParserMethods(asmToBuild);
                    eval.LoadMethodsCodes(methods);
                }
                Dictionary<string, List<MethodInfo>> dict = eval.GetExtensionGates();
                CompositeTools = dict.Keys.ToList();
                PropertiesPane.LoadParametrics(dict);

                ComputerModel generatedModel = parser.BuildModel(asmToBuild);
                InitFromModel(generatedModel);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }