AddVariableStack() public method

public AddVariableStack ( ) : void
return void
Example #1
0
        private void Apply_Click(object sender, EventArgs e)
        {
            mIsUpdateTextDirty = true;

            if (ResetOnApplyCheckBox.Checked)
            {
                ResetClick(null, null);
            }

            mClassLevelCodeContext = new CodeContext(null);

            try
            {
                ApplyRichTextBoxScript(ClassScopeTextBox);
            }
            catch
            {
                MessageBox.Show("Error parsing Class Scope script");
            }

            try
            {
                mClassLevelCodeContext.AddVariableStack();
                ApplyRichTextBoxScript(InitializeTextBox);

                mClassLevelCodeContext.RemoveVariableStack();
            }
            catch
            {
                MessageBox.Show("Error parsing Initialize script");
            }
        }
Example #2
0
        internal void PerformUpdateScript()
        {
            try
            {
                mClassLevelCodeContext.AddVariableStack();

                var richTextBox = UpdateTextBox;

                ApplyRichTextBoxScript(richTextBox, mIsUpdateTextDirty);

                mIsUpdateTextDirty = false;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on update");
            }
            finally
            {
                mClassLevelCodeContext.RemoveVariableStack();
            }
        }
        private bool ApplyConditionalBlocks(string[] allLines, IElement element, CodeContext codeContext, string fileName, ref int index)
        {
            bool succeeded = true;

            BlockType lastBlockType = BlockType.None;

            BlockType nextBlockType = ConditionalCodeBlock.GetBlockTypeStartingAt(allLines, index);

            List<ConditionalCodeBlock> conditionalBlocks = new List<ConditionalCodeBlock>();

            while (nextBlockType.LinksFromPreviousType(lastBlockType))
            {
                ConditionalCodeBlock ccb = ConditionalCodeBlock.GetConditionalBlockFrom(allLines, index);
                conditionalBlocks.Add(ccb);
                lastBlockType = nextBlockType;

                index += ccb.LineCountIncludingConditionLine;
                nextBlockType = ConditionalCodeBlock.GetBlockTypeStartingAt(allLines, index);

            }


            // Only one of these blocks can trigger
            foreach (ConditionalCodeBlock ccb in conditionalBlocks)
            {
                // This code context is for the contents of the condition.
                // For example, the i variable in a for-loop will have scope
                // limited to the application of the for-loop.
                codeContext.AddVariableStack();

                bool shouldExecute = BranchingParser.Self.DetermineIfShouldExecute(
                    this, codeContext, ccb, mExpressionParser, true);


                while (shouldExecute)
                {
                    codeContext.AddVariableStack();

                    int startBlock = ccb.FirstLineOfBlockIndex;
                    int blockLength = ccb.BlockLength;
                    if (ccb.IsBlockWrappedInBrackets)
                    {
                        startBlock++;
                        blockLength -= 2;
                    }
                    succeeded = ApplyLinesInternal(allLines, startBlock, blockLength, element, codeContext, fileName);

                    
                    shouldExecute = false;
                    if (succeeded)
                    {
                        if (ccb.BlockType == BlockType.For)
                        {
                            BranchingParser.Self.IncrementFor(codeContext, ccb, mExpressionParser);

                            shouldExecute = BranchingParser.Self.DetermineIfShouldExecute(
                                this, codeContext, ccb, mExpressionParser, false);
                        }
                        else if (ccb.BlockType == BlockType.While)
                        {
                            shouldExecute = BranchingParser.Self.DetermineIfShouldExecute(
                                this, codeContext, ccb, mExpressionParser, false);
                        }
                    }

                    codeContext.RemoveVariableStack();
                }
                codeContext.RemoveVariableStack();

            }

            return succeeded;
        }
        private void Apply_Click(object sender, EventArgs e)
        {
            mIsUpdateTextDirty = true;

            if (ResetOnApplyCheckBox.Checked)
            {
                ResetClick(null, null);
            }

            mClassLevelCodeContext = new CodeContext(null);

            try
            {
                ApplyRichTextBoxScript(ClassScopeTextBox);
            }
            catch
            {
                MessageBox.Show("Error parsing Class Scope script");
            }

            try
            {
                mClassLevelCodeContext.AddVariableStack();
                ApplyRichTextBoxScript(InitializeTextBox);

                mClassLevelCodeContext.RemoveVariableStack();
            }
            catch
            {
                MessageBox.Show("Error parsing Initialize script");
            }
        }