Exemplo n.º 1
0
        private void ExtractProcedure(Procedure procedure)
        {
            IStatementList children = procedure.Body;

            for (int i = 0; i < children.GetSize(); i++)
            {
                Statement child = children[i];
                ExtractStatement(child, procedure);
                if (i > 0)
                {
                    Statement previousChild = children[i - 1];
                    FollowsTable.SetFollows(previousChild, child);

                    if (!(previousChild is If))
                    {
                        NextTable.SetNext(previousChild, child);
                    }
                    else
                    {
                        ExtractIfNext(previousChild as If, child);
                    }
                }

                IVariableList modifiedVariables = ModifiesTable.GetModifiedBy(child);
                IVariableList usedVariables     = UsesTable.GetUsedBy(child);

                foreach (Variable variable in modifiedVariables)
                {
                    ModifiesTable.SetModifies(procedure, variable);
                }
                foreach (Variable variable in usedVariables)
                {
                    UsesTable.SetUses(procedure, variable);
                }
            }
        }
Exemplo n.º 2
0
        private void ExtractBody(Container container, IStatementList body, Procedure procedureContext)
        {
            for (int i = 0; i < body.GetSize(); i++)
            {
                Statement child = body[i];
                ExtractStatement(child, procedureContext);

                ParentTable.SetParent(container, child);
                if (i > 0)
                {
                    Statement previousChild = body[i - 1];
                    FollowsTable.SetFollows(previousChild, child);

                    if (!(previousChild is If))
                    {
                        NextTable.SetNext(previousChild, child);
                    }
                    else
                    {
                        ExtractIfNext(previousChild as If, child);
                    }
                }

                IVariableList modifiedVariables = ModifiesTable.GetModifiedBy(child);
                IVariableList usedVariables     = UsesTable.GetUsedBy(child);

                foreach (Variable variable in modifiedVariables)
                {
                    ModifiesTable.SetModifies(container, variable);
                }
                foreach (Variable variable in usedVariables)
                {
                    UsesTable.SetUses(container, variable);
                }
            }
        }