示例#1
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            RelElem Relem;

            try
            {
                Relem = repo_.stack2.pop();
                for (int i = 0; i < repo_.inheritance.Count; ++i)
                {
                    RelElem temp = repo_.inheritance[i];
                    if (Relem.type == temp.type)
                    {
                        if (Relem.name == temp.name)
                        {
                            if (Relem.withName == temp.withName)
                            {
                                if ((repo_.inheritance[i]).endRel == 0)
                                {
                                    (repo_.inheritance[i]).endRel = repo_.semi.lineCount - repo_.prevLineCount;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }
            CSsemi.CSemiExp local = new CSsemi.CSemiExp();
            local.Add(Relem.type).Add(Relem.name);
            if (local[0] == "control")
            {
                return;
            }

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount);
                Console.Write("leaving  ");
                string indent = new string(' ', 2 * (repo_.stack.count + 1));
                Console.Write("{0}", indent);
                this.display(local); // defined in abstract action
            }
        }
示例#2
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Display.displayActions(actionDelegate, "action SaveDeclar");
            Elem elem;

            try
            {
                elem = repo_.stack.pop();
                for (int i = 0; i < repo_.locations.Count; ++i)
                {
                    Elem temp = repo_.locations[i];
                    if (elem.type == temp.type)
                    {
                        if (elem.name == temp.name)
                        {
                            if ((repo_.locations[i]).endLine == 0)
                            {
                                (repo_.locations[i]).endLine       = repo_.semi.lineCount;
                                (repo_.locations[i]).endScopeCount = repo_.scopeCount;
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }
            CSsemi.CSemiExp local = new CSsemi.CSemiExp();
            local.Add(elem.type).Add(elem.name);
            if (local[0] == "control")
            {
                return;
            }

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount);
                Console.Write("leaving  ");
                string indent = new string(' ', 2 * (repo_.stack.count + 1));
                Console.Write("{0}", indent);
                this.display(local); // defined in abstract action
            }
        }
示例#3
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Elem elem;

            try
            {
                elem = repo_.stack.pop();
                for (int i = 0; i < repo_.analyzedata.Count; ++i)
                {
                    Elem temp = repo_.analyzedata[i];
                    if (elem.type == temp.type)
                    {
                        if (elem.name == temp.name)
                        {
                            if ((repo_.analyzedata[i]).end == 0)
                            {
                                (repo_.analyzedata[i]).end = repo_.semi.lineCount;
                                break;
                            }
                        }
                    }
                    if (temp.end == 0 && temp.type == "function")
                    {
                        temp.scopecount++;
                    }
                }
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }
            CSsemi.CSemiExp local = new CSsemi.CSemiExp();
            local.Add(elem.type).Add(elem.name);

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount);
                Console.Write("leaving  ");
                string indent = new string(' ', 2 * (repo_.stack.count + 1));
                Console.Write("{0}", indent);
                this.display(local); // defined in abstract action
            }
        }
示例#4
0
        /*This method will be called when we encounter the end
         * of scope for any type(class,function,struct etc).
         * At the end we append the ending line number for that type
         * */
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Elem elem = null;

            try
            {
                if (repo_.stack.count >= 1)
                {
                    elem = repo_.stack.pop();
                    for (int i = 0; i < repo_.locations.Count; ++i)
                    {
                        Elem temp = repo_.locations[i];
                        if (elem.type == temp.type)
                        {
                            if (elem.name == temp.name)
                            {
                                if ((repo_.locations[i]).end == 0)
                                {
                                    (repo_.locations[i]).end = repo_.semi.lineCount;
                                    break;
                                }
                            }
                        }
                        if (temp.end == 0 && temp.type == "function")
                        {
                            temp.scopecount++;
                        }
                    }
                }
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }

            if (elem != null)
            {
                CSsemi.CSemiExp local = new CSsemi.CSemiExp();
                local.Add(elem.type).Add(elem.name);
            }
        }
示例#5
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Elem elem;

            try
            {
                elem = repo_.stack.pop();
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }
            CSsemi.CSemiExp local = new CSsemi.CSemiExp();
            local.Add(elem.type).Add(elem.name);
            if (local[0] == "control")
            {
                return;
            }
        }
示例#6
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Elem elem;

            try
            {
                elem = repo_.stack.pop();

                //reverse for loop for anonymous scope

                if (elem.type.Equals("control"))
                {
                    for (int i = repo_.locations.Count - 1; i >= 0; --i)
                    {
                        Elem temp = repo_.locations[i];
                        if (elem.type == temp.type)
                        {
                            if (elem.name == temp.name)
                            {
                                if ((repo_.locations[i]).end == 0)
                                {
                                    (repo_.locations[i]).end = repo_.semi.lineCount;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < repo_.locations.Count; ++i)
                    {
                        Elem temp = repo_.locations[i];
                        if (elem.type == temp.type)
                        {
                            if (elem.name == temp.name)
                            {
                                if ((repo_.locations[i]).end == 0)
                                {
                                    (repo_.locations[i]).end = repo_.semi.lineCount;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }
            CSsemi.CSemiExp local = new CSsemi.CSemiExp();
            local.Add(elem.type).Add(elem.name);
            //if(local[0] == "control")
            // return;

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount);
                Console.Write("leaving  ");
                string indent = new string(' ', 2 * (repo_.stack.count + 1));
                Console.Write("{0}", indent);
                this.display(local); // defined in abstract action
            }
        }
示例#7
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Elem elem   = new Elem();
            bool isFunc = false;

            try
            {
                elem = repo_.stack.pop();
                if (elem.type == "delegate")
                {
                    return;
                }
                if (semi[0] == "control" || semi[0] == "anonymous")
                {
                    elem.prog_complexity = elem.prog_complexity + 1;
                }
                if (elem.type == "function")
                {
                    elem.prog_complexity  = repo_.prog_comp_count + 1;
                    repo_.prog_comp_count = 0;
                    Console.WriteLine("complexity: {0}", elem.prog_complexity);
                    isFunc = false;
                }

                // calculates the line count and sets the line count in the repository//
                for (int i = 0; i < repo_.locations.Count; ++i)
                {
                    Elem temp = repo_.locations[i];
                    if (elem.type == temp.type)
                    {
                        if (elem.name == temp.name)
                        {
                            if ((repo_.locations[i]).end == 0)
                            {
                                (repo_.locations[i]).end = repo_.semi.lineCount;
                                if (isFunc)
                                {
                                    (repo_.locations[i]).prog_complexity = elem.prog_complexity;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
                Console.Write("popped empty stack on semiExp: ");
                semi.display();
                return;
            }
            CSsemi.CSemiExp local = new CSsemi.CSemiExp();
            local.Add(elem.type).Add(elem.name);
            if (local[0] == "control")
            {
                return;
            }

            if (AAction.displaySemi)
            {
                elem.end  = repo_.semi.lineCount;
                elem.size = elem.end - elem.begin;
                string indent = new string(' ', 2 * (repo_.stack.count + 1));
                this.display(local); // defined in abstract action
            }
        }
示例#8
0
 public override void doAction(CSsemi.CSemiExp semi)
 {
     semi.display();
 }