Example #1
0
        //Pass the the items of a scope and it will generate necessary controls

        public void VcodeToVblock(Scope scope)
        {
            GlobalScopePanel.Controls.Clear();
            foreach (VCode item in scope.Items)
            {
                switch (item.VType)
                {
                case Enums.VType.Variable:
                    Vvariable vvariable = new Vvariable(item);

                    GlobalScopePanel.Controls.Add(vvariable);
                    break;

                case Enums.VType.Function:
                    Function  function  = (Function)item;
                    Vfunction vfunction = new Vfunction(function)
                    {
                        Width = GlobalScopePanel.Width
                    };

                    vfunction.ScopeControl.VcodeToVblock(function.Scope);
                    GlobalScopePanel.Controls.Add(vfunction);

                    break;
                }
            }
        }
Example #2
0
        private void variableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VariableProperties variableProperties = new VariableProperties();

            if (variableProperties.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Vvariable vvariable = new Vvariable(variableProperties.Variable);

            GlobalScopePanel.Controls.Add(vvariable);
            UpdateScope();
        }
        //Pass the the items of a scope and it will generate necessary controls

        public void VcodeToVblock(Scope scope)
        {
            foreach (VCode item in scope.Items)
            {
                switch (item.VType)
                {
                case Enums.VType.Variable:
                    Vvariable vvariable = new Vvariable(item);
                    ScopePanel.Controls.Add(vvariable);
                    break;

                case Enums.VType.Function:
                    Function function = (Function)item;

                    if (function.IsBody)
                    {
                        Vfunction vfunction = new Vfunction(function)
                        {
                            Width = ScopePanel.Width
                        };
                        vfunction.ScopeControl.VcodeToVblock(function.Scope);
                        ScopePanel.Controls.Add(vfunction);
                    }
                    else
                    {
                        FunctionCall vFunctionCall = new FunctionCall(function, scope.LocalVariables);
                        ScopePanel.Controls.Add(vFunctionCall);
                    }

                    break;

                case Enums.VType.If:
                    If  iif = (If)item;
                    Vif vif = new Vif(iif)
                    {
                        Width = ScopePanel.Width
                    };
                    vif.ScopeControl.VcodeToVblock(iif.Scope);
                    ScopePanel.Controls.Add(vif);
                    break;

                case Enums.VType.While:
                    While  wWhile = (While)item;
                    Vwhile vwhile = new Vwhile(wWhile)
                    {
                        Width = ScopePanel.Width
                    };
                    vwhile.ScopeControl.VcodeToVblock(wWhile.Scope);
                    ScopePanel.Controls.Add(vwhile);
                    break;

                case Enums.VType.Assignment:
                    Assignment      assignment      = (Assignment)item;
                    AssignmentBlock assignmentBlock = new AssignmentBlock(assignment, false);
                    ScopePanel.Controls.Add(assignmentBlock);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }