private void BeginCodeGeneration(GMacCodeLibraryComposer libGen) { GMacSystemUtils.ResetProgress(); var formProgress = new FormProgress(libGen.Progress, libGen.Generate, null); formProgress.ShowDialog(this); var formFiles = new FormFilesComposer(libGen.CodeFilesComposer); formFiles.ShowDialog(this); }
/// <summary> /// Given GMacDSL code this factory class compiles the code into a GMacAST structure and /// use the blades code library composer for C# to compose target C# code /// </summary> /// <param name="dslCode"></param> /// <param name="outputFolder"></param> /// <param name="generateMacros"></param> /// <param name="targetLanguageName"></param> /// <returns></returns> public static FilesComposer ComposeLibrary(string dslCode, string outputFolder, bool generateMacros, string targetLanguageName) { //Clear the progress log composer GMacSystemUtils.ResetProgress(); //Compile GMacDSL code into a GMacAST structure var ast = BeginCompilation(dslCode); //If compilation fails return nothing if (ReferenceEquals(ast, null)) { return(null); } //Create and initialize code library composer for C# GMacCodeLibraryComposer activeGenerator; //Select the composer based on the target language name switch (targetLanguageName) { case "C#": activeGenerator = new BladesLibrary(ast); break; default: activeGenerator = new BladesLibrary(ast); break; } //Set the output folder for generated files activeGenerator.CodeFilesComposer.RootFolder = outputFolder; //Select option for generating macros code, this takes the longest time //in the composition process and may be skipped initially while designing //structure of composed library activeGenerator.MacroGenDefaults.AllowGenerateMacroCode = generateMacros; //Specify GMacAST frames to be used for code compositions activeGenerator.SelectedSymbols.SetSymbols(ast.Frames); //Start code composition process and display its progress var formProgress = new FormProgress(activeGenerator.Progress, activeGenerator.Generate, null); formProgress.ShowDialog(); //Save all generated files //activeGenerator.CodeFilesComposer.SaveToFolder(); //Return generated folders\files as a FilesComposer object return(activeGenerator.CodeFilesComposer); }
private void SetScriptFromInterface() { GMacSystemUtils.ResetProgress(); textBoxOutput.Text = string.Empty; textBoxCSharpCode.Text = string.Empty; listViewErrors.Items.Clear(); textBoxErrorDetails.Text = string.Empty; _gmacScript.SetScript( textBoxScript.Text, textBoxMembers.Text, _usedNamespaces, Enumerable.Empty <string>() ); }
private void GenerateMacro() { listBoxGenerationStage.Items.Clear(); textBoxDisplay.Text = String.Empty; Graph = null; if (UpdateMacroBinding() == false) { return; } GMacSystemUtils.ResetProgress(); MacroCodeGenerator = new SingleMacroGen(MacroBinding) { MacroGenDefaults = { AllowGenerateMacroCode = true } }; GenerateMacro_DslCode(); GenerateMacro_ParsedBody(); GenerateMacro_CompiledBody(); GenerateMacro_OptimizedBody(); GenerateMacro_SampleTargetCode(); ProgressHistory = MacroCodeGenerator .Progress .History .ReadHistory() .ToDictionary(item => item.ProgressId); foreach (var item in ProgressHistory) { listBoxGenerationStage.Items.Add(item.Value.FullTitle); } Graph = MacroCodeGenerator.Graph; }
private void buttonExecTask_Click(object sender, EventArgs e) { textBoxResults.Text = String.Empty; var task = listBoxTasks.SelectedItem as CodeGenSampleTask; if (ReferenceEquals(task, null)) { MessageBox.Show( @"Please select a task to execute", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); return; } GMacSystemUtils.ResetProgress(); textBoxResults.Text = task.TaskAction(); }
private void SetInterfaceFromScript() { GMacSystemUtils.ResetProgress(); textBoxOutput.Text = string.Empty; textBoxCSharpCode.Text = string.Empty; listViewErrors.Items.Clear(); textBoxErrorDetails.Text = string.Empty; textBoxScript.Text = _gmacScript.ScriptText; textBoxMembers.Text = _gmacScript.ScriptClassMembersText; _usedNamespaces.Clear(); _usedNamespaces.AddRange(GMacScriptManager.DefaultNamespacesList); if (_gmacScript.OpenedNamespaces != null) { _usedNamespaces.AddRange( _gmacScript .OpenedNamespaces .Where(ns => _usedNamespaces.Contains(ns) == false) ); } }
private bool CompileSourceFiles(bool forceCompilation = false) { if (AskSaveSourceCode() == false) { return(false); } ResetCompilationInterface(); var startCompilationTime = DateTime.Now; textBoxOutputLog.Text = startCompilationTime.ToLongTimeString() + @" Start Compilation" + Environment.NewLine; Application.DoEvents(); GMacSystemUtils.ResetProgress(); _dslCompiler.Compile(_dslProject, forceCompilation); var endCompilationTime = DateTime.Now; textBoxOutputLog.Text += _dslCompiler.CompilationLog.Progress.History.ToString(); //textBoxOutputLog.Text += _dslCompiler.CompilationLog.TimeCounter.RootEventsSpanToString(); textBoxOutputLog.Text += endCompilationTime.ToLongTimeString() + @" End Compilation " + (_dslCompiler.CompilationLog.HasErrors ? @"with errors " : String.Empty) + @"after " + (endCompilationTime - startCompilationTime) + Environment.NewLine; FillErrorList(_dslCompiler.CompilationLog); FillWarningList(_dslCompiler.CompilationLog); UpdateInterface_SourceFilesList(); if (_dslCompiler.CompilationLog.HasErrors) { listViewErrors.SelectedIndices.Add(0); tabControl2.SelectedTab = tabPageErrors; MarkSelectedError(); } else { _astRoot = _dslCompiler.RootGMacAst; FillComponentsTree(); tabControl1.SelectedTab = tabPageComponents; } return(true); }
private void GenerateMacro() { listBoxGenerationStage.Items.Clear(); textBoxDisplay.Text = String.Empty; Graph = null; if (UpdateMacroBindingTextData() == false) { return; } GMacSystemUtils.ResetProgress(); MacroBinding = GMacMacroBinding.Create(SelectedMacro); MacroCodeGenerator = new SingleMacroGen(MacroBinding) { MacroGenDefaults = { AllowGenerateMacroCode = true } }; foreach (var bindingData in BindingTextData.Bindings) { if (bindingData.IsConstantBinding) { MacroBinding.BindScalarToConstant( bindingData.ValueAccessName, bindingData.ConstantValueText ); continue; } var testValueExpr = bindingData.HasTestValue ? bindingData.TestValueText.ToExpr(SymbolicUtils.Cas) : null; MacroBinding.BindToVariables(bindingData.ValueAccessName, testValueExpr); if (bindingData.HasTargetVariableName) { MacroCodeGenerator .TargetVariablesNamesDictionary.Add( bindingData.ValueAccessName, bindingData.TargetVariableName ); } } GenerateMacro_DslCode(); GenerateMacro_ParsedBody(); GenerateMacro_CompiledBody(); GenerateMacro_OptimizedBody(); GenerateMacro_RawBodyCallCode(); GenerateMacro_ParsedBodyCallCode(); GenerateMacro_CompiledBodyCallCode(); GenerateMacro_OptimizedBodyCallCode(); GenerateMacro_SampleTargetCode(); ProgressHistory = MacroCodeGenerator .Progress .History .ReadHistory() .ToDictionary(item => item.ProgressId); foreach (var item in ProgressHistory) { listBoxGenerationStage.Items.Add(item.Value.FullTitle); } Graph = MacroCodeGenerator.Graph; }