Beispiel #1
0
        public static void DefaultGenerateCommentsBeforeComputations(GMacMacroCodeComposer macroCodeGen)
        {
            macroCodeGen.SyntaxList.Add(
                macroCodeGen.SyntaxFactory.Comment(
                    "Bagin GMac Macro Code Generation, " + DateTime.Now.ToString("O")
                    )
                );

            macroCodeGen.SyntaxList.Add(
                macroCodeGen.SyntaxFactory.Comment("Macro: " + macroCodeGen.CodeBlock.BaseMacro.AccessName)
                );

            macroCodeGen.SyntaxList.Add(
                macroCodeGen.SyntaxFactory.Comment(
                    macroCodeGen
                    .CodeBlock
                    .GetStatisticsReport()
                    .Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)
                    )
                );

            IGMacCbParameterVariable paramVar;

            var commentTextLines =
                macroCodeGen
                .MacroBinding
                .Bindings
                .Select(
                    p =>
            {
                var s = new StringBuilder();

                s.Append("   ").Append(p.ValueAccessName).Append(" <=> ");

                if (p.IsConstant)
                {
                    return(s.Append("<Constant> ").Append(p.ConstantValue).ToString());
                }

                if (macroCodeGen.CodeBlock.TryGetParameterVariable(p.ValueAccess, out paramVar))
                {
                    return(s.Append("<Variable> ").Append(paramVar.TargetVariableName).ToString());
                }

                return(s.Append("<Constant> 0, the parameter binding was not found in the code block!!").ToString());
            })
                .ToArray();

            macroCodeGen.SyntaxList.Add(
                macroCodeGen.SyntaxFactory.Comment()
                );

            macroCodeGen.SyntaxList.Add(
                macroCodeGen.SyntaxFactory.Comment("Macro Binding Data: ")
                );

            macroCodeGen.SyntaxList.Add(macroCodeGen.SyntaxFactory.Comment(commentTextLines));

            macroCodeGen.SyntaxList.AddEmptyLine();
        }
Beispiel #2
0
        public static bool DefaultActionBeforeGenerateComputations(GMacMacroCodeComposer macroCodeGen)
        {
            DefaultGenerateCommentsBeforeComputations(macroCodeGen);

            GenerateDeclareTempsCode(macroCodeGen);

            return(true);
        }
Beispiel #3
0
 public static void DefaultGenerateCommentsAfterComputations(GMacMacroCodeComposer macroCodeGen)
 {
     macroCodeGen.SyntaxList.Add(
         macroCodeGen.SyntaxFactory.Comment(
             "Finish GMac Macro Code Generation, " + DateTime.Now.ToString("O")
             )
         );
 }
Beispiel #4
0
        private static void GenerateDeclareTempsCode(GMacMacroCodeComposer macroCodeGen)
        {
            var tempVarNames =
                macroCodeGen.CodeBlock
                .TempVariables
                .Select(item => item.TargetVariableName)
                .Distinct();

            //Add temp variables declaration code
            foreach (var tempVarName in tempVarNames)
            {
                macroCodeGen.SyntaxList.Add(
                    macroCodeGen
                    .GMacLanguage
                    .SyntaxFactory
                    .DeclareLocalVariable(macroCodeGen.GMacLanguage.ScalarTypeName, tempVarName)
                    );
            }

            macroCodeGen.SyntaxList.AddEmptyLine();
        }
Beispiel #5
0
 protected virtual void InitializeGenerator(GMacMacroCodeComposer macroCodeGen)
 {
 }
Beispiel #6
0
 protected GMacMacroCodeFileComposer(GMacMacroCodeComposer macroCodeGen)
     : base(macroCodeGen.LibraryComposer)
 {
     MacroCodeGenerator = macroCodeGen;
 }
Beispiel #7
0
 protected GMacMacroCodeFileComposer(GMacMacroCodeComposerDefaults defaults, AstMacro baseMacro = null)
     : base(defaults.LibraryComposer)
 {
     MacroCodeGenerator = new GMacMacroCodeComposer(defaults, baseMacro);
 }
Beispiel #8
0
 protected GMacMacroCodeFileComposer(GMacCodeLibraryComposer libGen, AstMacro baseMacro = null)
     : base(libGen)
 {
     MacroCodeGenerator = new GMacMacroCodeComposer(libGen, baseMacro);
 }
Beispiel #9
0
 public static void DefaultActionAfterGenerateComputations(GMacMacroCodeComposer macroCodeGen)
 {
     DefaultGenerateCommentsAfterComputations(macroCodeGen);
 }