Ejemplo n.º 1
0
        public static DotGraph ToLowLevelGraphViz(this AstMacro macro)
        {
            var random = new Random();

            var macroBinding = GMacMacroBinding.Create(macro);

            var lowLevelParameters = macro.InputParameters.SelectMany(p => p.DatastoreValueAccess.ExpandAll());

            foreach (var llp in lowLevelParameters)
            {
                if (random.Next(1, 10) > -1)
                {
                    macroBinding.BindToVariables(llp);
                }

                else
                {
                    macroBinding.BindScalarToConstant(llp, 1);
                }
            }

            lowLevelParameters = macro.OutputParameter.DatastoreValueAccess.ExpandAll();
            foreach (var llp in lowLevelParameters)
            {
                macroBinding.BindToVariables(llp);
            }

            var codeBlock = macroBinding.CreateOptimizedCodeBlock();

            //var visitor = new MacroBindingToGraphViz(macroBinding, codeBlock);
            var visitor = new GMacCodeBlockToGraphViz(codeBlock);

            return(visitor.ToGraphViz());
        }
Ejemplo n.º 2
0
        private void GenerateMacroCode(AstMacro macro)
        {
            var macroBinding = GMacMacroBinding.Create(macro);

            InitializeFullMacroBinding(macroBinding);

            GenerateMacroCode(macroBinding);
        }
Ejemplo n.º 3
0
        public GMacMacroCodeComposer(GMacMacroCodeComposerDefaults codeGenDefaults, AstMacro baseMacro = null)
            : base(codeGenDefaults.LibraryComposer)
        {
            SyntaxList = new SteSyntaxElementsList();

            MacroBinding = baseMacro.IsNullOrInvalid() ? null : GMacMacroBinding.Create(baseMacro);

            UsedDefaults = codeGenDefaults.Duplicate();

            SetDefaults();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Used to replace the base macro by another one. This sets the defaults of the generator and clears
        /// the internal code composer
        /// </summary>
        /// <param name="baseMacro"></param>
        public void SetBaseMacro(AstMacro baseMacro)
        {
            SyntaxList.Clear();

            CodeBlock = null;

            TargetVariablesNaming = null;

            MacroBinding = GMacMacroBinding.Create(baseMacro);

            SetDefaults();
        }
Ejemplo n.º 5
0
        private bool UpdateMacroBinding()
        {
            var result = true;

            textBoxDisplay.Text = String.Empty;

            MacroBinding =
                GMacMacroBinding.Create(
                    SelectedMacro
                    );

            var paramText =
                textBoxParameters
                .Text
                .SplitLines()
                .Select(line => line.Trim())
                .Where(line => String.IsNullOrEmpty(line) == false);

            foreach (var line in paramText)
            {
                try
                {
                    AddMacroParameterBinding(line);
                }
                catch (Exception e)
                {
                    textBoxDisplay.Text +=
                        new StringBuilder()
                        .AppendLine("Error parsing macro parameter binding at:")
                        .Append("    ").AppendLine(line)
                        .AppendLine("Error Message: ")
                        .Append("    ").AppendLine(e.Message)
                        .AppendLine()
                        .ToString();

                    result = false;
                }
            }

            return(result);
        }
Ejemplo n.º 6
0
        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;
        }