private void GenerateFrameCode(AstFrame frameInfo) { Progress.Enabled = true; var progressId = this.ReportStart( "Generating code files for frame " + frameInfo.AccessName ); CurrentFrame = frameInfo; CurrentFrameName = GetSymbolTargetName(CurrentFrame); CodeFilesComposer.DownFolder(CurrentFrameName); GenerateBladeFiles(); GenerateVectorFiles(); GenerateFctoredBladeFiles(); GenerateOutermorphismFiles(); CodeFilesComposer.UpFolder(); Progress.Enabled = true; this.ReportFinish(progressId); }
private void GenerateFrameCode(AstFrame frameInfo) { Progress.Enabled = true; var progressId = this.ReportStart( "Generating code files for frame " + frameInfo.AccessName ); CurrentFrame = frameInfo; CurrentFrameName = GetSymbolTargetName(CurrentFrame); CodeFilesComposer.DownFolder(CurrentFrameName); InitializeMultivectorClassesData(); GenerateBaseMvClassFile(); foreach (var classData in MultivectorClassesData.Values) { GenerateDerivedMvClassFiles(classData); } //GenerateFctoredBladeFiles(); //GenerateOutermorphismFiles(); CodeFilesComposer.UpFolder(); Progress.Enabled = true; this.ReportFinish(progressId); }
private void GenerateFactorFiles() { var gmacStructInfo = AddFactorGMacStructure(); if (gmacStructInfo.IsNullOrInvalid()) { return; } var factorMacroList = AddFactorGMacMacros(); if (factorMacroList.Any(s => s.IsNullOrInvalid())) { return; } CodeFilesComposer.InitalizeFile("Factor.cs"); var fileGen = new FactorMainMethodsFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); for (var inGrade = 2; inGrade <= CurrentFrame.VSpaceDimension; inGrade++) { for (var inIndex = 0; inIndex < CurrentFrame.KvSpaceDimension(inGrade); inIndex++) { var inId = CurrentFrame.BasisBladeId(inGrade, inIndex); GenerateFactorMethod(inGrade, inId, factorMacroList[inGrade - 2]); } } }
private void GenerateFrameCode(AstFrame frameInfo) { CodeFilesComposer.InitalizeFile(frameInfo.Name + ".cs", GenerateCodeFileStartCode); ActiveFileTextComposer.AppendLineAtNewLine(@"public static class " + frameInfo.Name); ActiveFileTextComposer.AppendLineAtNewLine("{"); ActiveFileTextComposer.IncreaseIndentation(); GenerateFrameMultivectorCode(frameInfo.FrameMultivector); ActiveFileTextComposer.AppendLineAtNewLine(); foreach (var constantInfo in frameInfo.Constants) { GenerateConstantCode(constantInfo); } foreach (var macroInfo in frameInfo.Macros) { GenerateMacroCode(macroInfo); } ActiveFileTextComposer.DecreaseIndentation(); ActiveFileTextComposer.AppendLineAtNewLine("}"); CodeFilesComposer.UnselectActiveFile(GenerateCodeFileEndCode); }
/// <summary> /// Performs text files generation based on the given AST information. /// This method calls InitializeGenerator(), composeTextFilesAction(), then FinalizeGenerator(). /// </summary> /// <param name="composeTextFilesAction"></param> public void Generate(Action composeTextFilesAction) { if (this.SetProgressRunning() == false) { return; } if (VerifyReadyToGenerate() == false) { this.SetProgressNotRunning(); return; } InitializeGenerator(); try { composeTextFilesAction(); } catch (OperationCanceledException e) { this.ReportError(e); } finally { CodeFilesComposer.FinalizeAllFiles(); FinalizeGenerator(); this.SetProgressNotRunning(); } }
private void GenerateBaseMvClassFile() { CodeFilesComposer.InitalizeFile(CurrentFrameName + "Multivector.cs"); BaseMvClassFileGenerator.Generate(this); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateBladeInvolutionMethodsFile() { CodeFilesComposer.InitalizeFile("Involutions.cs"); var fileGen = new InvolutionMethodsFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateBladeStaticUtilsFile() { CodeFilesComposer.InitalizeFile(CurrentFrameName + "BladeUtils.cs"); var fileGen = new StaticCodeFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateBladeMiscMethodsFile() { CodeFilesComposer.InitalizeFile("Misc.cs"); var fileGen = new MiscMethodsFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateFctoredBladeClassFile() { CodeFilesComposer.InitalizeFile(CurrentFrameName + "FactoredBlade.cs"); var fileGen = new FactoredBladeClass.ClassFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateOutermorphismClassFile() { CodeFilesComposer.InitalizeFile(CurrentFrameName + "Outermorphism.cs"); var fileGen = new OutermorphismClass.ClassFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateApplyVersorMainMethod(string opName) { CodeFilesComposer.InitalizeFile(opName + ".cs"); var fileGen = new ApplyVersorMainMethodFileGenerator(this, opName); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateVectorClassFile() { CodeFilesComposer.InitalizeFile(CurrentFrameName + "Vector.cs"); var fileGen = new VectorClass.ClassFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateOutermorphismApplyMethodFile(int inGrade) { CodeFilesComposer.InitalizeFile("Apply_" + inGrade + ".cs"); var fileGen = new ApplyMethodFileGenerator(this, inGrade); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateSelfEuclideanGeometricProductFile() { const string opName = DefaultMacro.EuclideanUnary.SelfGeometricProduct; CodeFilesComposer.InitalizeFile(opName + ".cs"); var codeGen = new SelfEgpMethodsFileGenerator(this, opName); codeGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateDeltaProductDualFile() { const string opName = "DPDual"; CodeFilesComposer.InitalizeFile(opName + ".cs"); var codeGen = new DpDualMethodsFileGenerator(this, opName); codeGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
private void GenerateVectorFiles() { int progressId = this.ReportStart( "Generating Vector class code files for frame " + CurrentFrame.AccessName ); CodeFilesComposer.DownFolder("Vector"); GenerateVectorClassFile(); CodeFilesComposer.UpFolder(); this.ReportFinish(progressId); }
private void GenerateFactorMethod(int inGrade, int inId, AstMacro gmacMacroInfo) { CodeFilesComposer.DownFolder("Factor"); CodeFilesComposer.InitalizeFile("Factor" + inId + ".cs"); var fileGen = new FactorMethodFileGenerator(this, inGrade, inId, gmacMacroInfo); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); CodeFilesComposer.UpFolder(); }
private void GenerateFctoredBladeFiles() { var progressId = this.ReportStart( "Generating FactoredBlade class code files for frame " + CurrentFrame.AccessName ); CodeFilesComposer.DownFolder("FactoredBlade"); GenerateFctoredBladeClassFile(); CodeFilesComposer.UpFolder(); this.ReportFinish(progressId); }
private void GenerateBladeClassFile() { CodeFilesComposer.InitalizeFile(CurrentFrameName + "Blade.cs"); var fileGen = new BladeClass.ClassFileGenerator(this); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); //Note: You can use this method instead to finalize, save, free memory, //and unselect the active file composer in one step during code generation //when the you are done with the file: //CodeFilesComposer.SaveActiveFile(); }
private void GenerateBilinearProductMainMethodFile(string opName, string zeroCondition, Func <int, int, int> getFinalGrade, Func <int, int, bool> isLegalGrade) { CodeFilesComposer.InitalizeFile(opName + ".cs"); var fileGen = new BilinearProductMainMethodFileGenerator( this, opName, zeroCondition, getFinalGrade, isLegalGrade ); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
protected override void ComposeTextFiles() { CodeFilesComposer.InitalizeFile(MacroBinding.BaseMacro.Name + ".cs"); var codeBlock = GenerateMacroCode(MacroBinding); CodeFilesComposer.UnselectActiveFile(); Graph = codeBlock.ToGraphViz(); var progressId = this.ReportStart("Generate GraphViz Code"); Graph.GenerateDotCode(); this.ReportFinish(progressId); }
private void GenerateVectorsOuterProductFile() { var macroInfo = AddVectorsOuterProductGMacMacro(); if (macroInfo.IsNullOrInvalid()) { return; } CodeFilesComposer.InitalizeFile("VectorsOP.cs"); var fileGen = new VectorsOpMethodsFileGenerator(this, macroInfo); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
protected override void ComposeTextFiles() { var framesList = SelectedSymbols.Cast <AstFrame>(); CodeFilesComposer.DownFolder("GMacDSL"); foreach (var frame in framesList) { CodeFilesComposer.InitalizeFile("frame_" + GetSymbolTargetName(frame) + ".gmac"); GenerateFrameCode(frame); CodeFilesComposer.UnselectActiveFile(); } CodeFilesComposer.UpFolder(); }
private void GenerateNamespaceCode(AstNamespace namespaceInfo) { _currentNamespace = namespaceInfo; CodeFilesComposer.DownFolder(namespaceInfo.Name); CodeFilesComposer.InitalizeFile(namespaceInfo.Name + "Utils.cs", GenerateCodeFileStartCode); ActiveFileTextComposer.AppendLineAtNewLine(@"public static class " + namespaceInfo.Name + "Utils"); ActiveFileTextComposer.AppendLineAtNewLine("{"); ActiveFileTextComposer.IncreaseIndentation(); foreach (var constantInfo in namespaceInfo.ChildConstants) { GenerateConstantCode(constantInfo); } foreach (var macroInfo in namespaceInfo.ChildMacros) { GenerateMacroCode(macroInfo); } ActiveFileTextComposer.DecreaseIndentation(); ActiveFileTextComposer.AppendLineAtNewLine("}"); CodeFilesComposer.UnselectActiveFile(GenerateCodeFileEndCode); foreach (var frameInfo in namespaceInfo.ChildFrames) { GenerateFrameCode(frameInfo); } foreach (var structureInfo in namespaceInfo.ChildStructures) { GenerateStructureCode(structureInfo); } foreach (var childNamespaceInfo in namespaceInfo.ChildNamespaces) { GenerateNamespaceCode(childNamespaceInfo); } CodeFilesComposer.UpFolder(); }
private void GenerateStructureCode(AstStructure structureInfo) { CodeFilesComposer.InitalizeFile(structureInfo.Name + ".cs", GenerateCodeFileStartCode); ActiveFileTextComposer.AppendAtNewLine(@"public sealed class "); ActiveFileTextComposer.AppendLine(structureInfo.Name); ActiveFileTextComposer.AppendLineAtNewLine("{"); ActiveFileTextComposer.IncreaseIndentation(); foreach (var memberInfo in structureInfo.DataMembers) { ActiveFileTextComposer.AppendAtNewLine("public "); GenerateTypeName(memberInfo.GMacType); ActiveFileTextComposer.Append(" "); ActiveFileTextComposer.Append(memberInfo.Name); ActiveFileTextComposer.AppendLine(" { get; set; }"); ActiveFileTextComposer.AppendLine(); } ActiveFileTextComposer.AppendLine(); ActiveFileTextComposer.AppendAtNewLine("public "); ActiveFileTextComposer.Append(structureInfo.Name); ActiveFileTextComposer.AppendLine("()"); ActiveFileTextComposer.Append("{"); ActiveFileTextComposer.IncreaseIndentation(); foreach (var memberInfo in structureInfo.DataMembers.Where(memberInfo => !memberInfo.GMacType.IsValidPrimitiveType)) { ActiveFileTextComposer.AppendAtNewLine(memberInfo.Name); ActiveFileTextComposer.Append(" = "); GenerateTypeDefaultValue(memberInfo.GMacType); ActiveFileTextComposer.AppendLine(";"); } ActiveFileTextComposer.DecreaseIndentation(); ActiveFileTextComposer.Append("}"); ActiveFileTextComposer.DecreaseIndentation(); ActiveFileTextComposer.AppendLineAtNewLine("}"); CodeFilesComposer.UnselectActiveFile(GenerateCodeFileEndCode); }
private void GenerateBladeNormMethodsFile() { var operatorNames = new[] { DefaultMacro.MetricUnary.NormSquared, DefaultMacro.MetricUnary.Magnitude, DefaultMacro.MetricUnary.MagnitudeSquared, DefaultMacro.EuclideanUnary.Magnitude, DefaultMacro.EuclideanUnary.MagnitudeSquared }; CodeFilesComposer.InitalizeFile("Norms.cs"); var fileGen = new NormMethodsFileGenerator(this, operatorNames); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); }
/// <summary> /// Initializes the text file generation process. This method must be called before /// any generation process /// </summary> protected void InitializeGenerator() { //Call initialize templates if needed if (TemplatesReady == false) { TemplatesReady = InitializeTemplates(); } //For each template, clear all parameters bindings foreach (var template in Templates.Values) { template.ClearBindings(); } //Clear the contents of the files composer CodeFilesComposer.Clear(); //Initialize any other components of a generator sub-class inherited from this one InitializeOtherComponents(); }
private void GenerateApplyVersorFunction(string opName, string funcName, int inGrade1, int inGrade2, int outGrade) { CodeFilesComposer.DownFolder(opName); CodeFilesComposer.InitalizeFile(funcName + ".cs"); var fileGen = new ApplyVersorMethodFileGenerator( this, opName, funcName, inGrade1, inGrade2, outGrade ); fileGen.Generate(); CodeFilesComposer.UnselectActiveFile(); CodeFilesComposer.UpFolder(); }
private void GenerateDerivedMvClassFiles(MvClassData classData) { CodeFilesComposer.DownFolder(classData.ClassName); CodeFilesComposer.InitalizeFile(classData.ClassName + ".cs"); DerivedMvClassFileGenerator.Generate(this, classData); CodeFilesComposer.UnselectActiveFile(); foreach (var classData2 in MultivectorClassesData.Values) { CodeFilesComposer.InitalizeFile(classData.ClassName + "Calc" + classData2.ClassId + ".cs"); DerivedMvClassCalcFileGenerator.Generate(this, classData, classData2); CodeFilesComposer.UnselectActiveFile(); } CodeFilesComposer.UpFolder(); }