Пример #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();
        }
Пример #2
0
        public static bool DefaultActionBeforeGenerateComputations(GMacMacroCodeComposer macroCodeGen)
        {
            DefaultGenerateCommentsBeforeComputations(macroCodeGen);

            GenerateDeclareTempsCode(macroCodeGen);

            return(true);
        }
Пример #3
0
 public static void DefaultGenerateCommentsAfterComputations(GMacMacroCodeComposer macroCodeGen)
 {
     macroCodeGen.SyntaxList.Add(
         macroCodeGen.SyntaxFactory.Comment(
             "Finish GMac Macro Code Generation, " + DateTime.Now.ToString("O")
             )
         );
 }
Пример #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();
        }
Пример #5
0
 protected virtual void InitializeGenerator(GMacMacroCodeComposer macroCodeGen)
 {
 }
Пример #6
0
 protected GMacMacroCodeFileComposer(GMacMacroCodeComposer macroCodeGen)
     : base(macroCodeGen.LibraryComposer)
 {
     MacroCodeGenerator = macroCodeGen;
 }
Пример #7
0
 protected GMacMacroCodeFileComposer(GMacMacroCodeComposerDefaults defaults, AstMacro baseMacro = null)
     : base(defaults.LibraryComposer)
 {
     MacroCodeGenerator = new GMacMacroCodeComposer(defaults, baseMacro);
 }
Пример #8
0
 protected GMacMacroCodeFileComposer(GMacCodeLibraryComposer libGen, AstMacro baseMacro = null)
     : base(libGen)
 {
     MacroCodeGenerator = new GMacMacroCodeComposer(libGen, baseMacro);
 }
Пример #9
0
 public static void DefaultActionAfterGenerateComputations(GMacMacroCodeComposer macroCodeGen)
 {
     DefaultGenerateCommentsAfterComputations(macroCodeGen);
 }