Exemple #1
0
        /// <summary>
        /// Optimize the compiled body of the given macro
        /// </summary>
        /// <param name="baseMacro"></param>
        /// <returns></returns>
        public static CommandBlock OptimizeMacro(GMacMacro baseMacro)
        {
            var optimizer = new HlOptimizer(baseMacro)
            {
                _optimizedBlock = CommandBlock.Create(baseMacro)
            };

            optimizer.Optimize();

            return(optimizer._optimizedBlock);
        }
Exemple #2
0
        //public override void ResetOnAcquire()
        //{
        //    base.ResetOnAcquire();

        //    _generatedBlock = null;
        //}

        protected override void Translate()
        {
            //Create the command block
            _generatedBlock = CommandBlock.Create(Context.ActiveParentScope);

            Context.PushState(_generatedBlock.ChildCommandBlockScope);

            //Begin translation of the composite expression commands
            var nodeBlockExpressionCommandsList = RootParseNode.ChildNodes[0];

            foreach (var subnode in nodeBlockExpressionCommandsList.ChildNodes)
            {
                GMacCommandGenerator.Translate(Context, subnode);
            }

            Context.PopState();
        }
Exemple #3
0
        internal static CommandBlock Compile(CommandBlock macroCommandBlock)
        {
            if (!(macroCommandBlock.ParentLanguageSymbol is GMacMacro))
            {
                throw new InvalidOperationException("The given command block is not a macro body");
            }

            var baseMacro = (GMacMacro)macroCommandBlock.ParentLanguageSymbol;

            var compiler = new HlMacroBodyCompiler(baseMacro);

            compiler._compiledBlock = CommandBlock.Create(compiler.BaseMacro);

            foreach (var param in compiler.BaseMacro.Parameters)
            {
                compiler.ActiveAr.AddSymbolData(param, param);
            }

            macroCommandBlock.AcceptVisitor(compiler);

            return(compiler._compiledBlock);
        }
Exemple #4
0
        /// <summary>
        /// The main Reset method called by all others. The given symbol must be a frame or a namespace
        /// </summary>
        /// <param name="symbol"></param>
        public void Reset(AstSymbol symbol)
        {
            if (symbol.IsNullOrInvalid() || (symbol.IsValidFrame == false && symbol.IsValidNamespace == false))
            {
                this.ReportNormal("Reset Interpreter", ProgressEventArgsResult.Failure);

                return;
            }

            Output.Clear();

            Root = symbol.Root;

            _mainCommandBlock = CommandBlock.Create(symbol.AssociatedSymbol as SymbolWithScope);

            RefResContext.Clear(_mainCommandBlock);

            _expressionEvaluator = GMacExpressionEvaluator.CreateForDynamicEvaluation(_mainCommandBlock);

            _symbolsCache.Clear();

            this.ReportNormal("Reset Interpreter", symbol.AccessName, ProgressEventArgsResult.Success);
        }