Exemple #1
0
        private void Compile(bool isCompressed)
        {
            try
            {
                compiler.Source = blockEditor.GetSource();

                var saveDialog = new SaveFileDialog
                {
                    Filter = "응용 프로그램 (*.exe)|*.exe"
                };

                if (saveDialog.ShowDialog().Value)
                {
                    var result = compiler.Build(saveDialog.FileName, isCompressed, isCompressed, false);

                    if (result.IsSuccess)
                    {
                        MessageBox.Show("컴파일을 성공하였습니다.", "성공", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show(result.Results.Errors[0].ErrorText, "오류", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "오류", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // 코드 생성
            GEntry entry = new GEntry();

            GVariable var = new GVariable("valueA");
            GDefine   def = new GDefine(var);

            entry.Append(def);

            GEvent main     = new GEvent(new GCommand("this", "Loaded", typeof(void), GCommand.CommandType.Event));
            GSet   setValue = new GSet(var, new GNumberConst(5));

            main.Append(setValue);

            GIf ifCheck = new GIf(new GCompare(var, GCompare.ConditionType.GREATER_THEN, new GNumberConst(3)));

            ifCheck.Append(
                new GVoidCall(
                    new GCommand("Console", "WriteLine", typeof(void), GCommand.CommandType.Call),
                    new GObject[] { new GStringCat(new GStringConst("A"), new GConvertNumberToString(new GNumberConst(5))) }
                    )
                );

            main.Append(ifCheck);
            entry.Append(main);

            // 생성된 코드 컴파일
            string source     = entry.ToSource();
            string resultFile = Path.GetTempFileName();

            GCompiler        compile = new GCompiler(source);
            GCompilerResults result  = compile.Build(resultFile);

            Console.WriteLine(result.Source);

            // 코드 컴파일 결과 분석
            if (result.IsSuccess)
            {
                // 컴파일 성공
                // 컴파일된 시나리오 실행
                Console.WriteLine("컴파일 성공");
            }
            else
            {
                // 컴파일 실패
                // 컴파일 오류 출력
                foreach (CompilerError error in result.Results.Errors)
                {
                    Console.WriteLine("컴파일 오류 : " + error.Line + " - " + error.ErrorNumber + ":" + error.ErrorText);
                }
            }

            Console.ReadLine();
        }
Exemple #3
0
        private void Compile(bool isCompressed)
        {
            compiler.Source = blockEditor.GetSource();

            var saveDialog = new SaveFileDialog
            {
                Filter = "응용 프로그램 (*.exe)|*.exe"
            };

            if (saveDialog.ShowDialog().Value)
            {
                var result = compiler.Build(saveDialog.FileName, isCompressed, isCompressed);
                MessageBox.Show(result.IsSuccess ? "컴파일 성공" : "컴파일 실패", "결과", MessageBoxButton.OK, result.IsSuccess ? MessageBoxImage.Information : MessageBoxImage.Error);
            }
        }