public override void doAction(ITokenCollection semi)
    {
      Display.displayActions(actionDelegate, "action PushStack");
      ++repo_.scopeCount;
      Elem elem = new Elem();
      elem.type = semi[0];     // expects type, i.e., namespace, class, struct, ..
      elem.name = semi[1];     // expects name
      elem.beginLine = repo_.semi.lineCount() - 1;
      elem.endLine = 0;        // will be set by PopStack action
      elem.beginScopeCount = repo_.scopeCount;
      elem.endScopeCount = 0;  // will be set by PopStack action
      repo_.stack.push(elem);

      // display processing details if requested

      if (AAction.displayStack)
        repo_.stack.display();
      if (AAction.displaySemi)
      {
        Console.Write("\n  line# {0,-5}", repo_.semi.lineCount() - 1);
        Console.Write("entering ");
        string indent = new string(' ', 2 * repo_.stack.count);
        Console.Write("{0}", indent);
        this.display(semi); // defined in abstract action
      }

      // add starting location if namespace, type, or function

      if (elem.type == "control" || elem.name == "anonymous")
        return;
      repo_.locations.Add(elem);
    }
示例#2
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Display.displayActions(actionDelegate, "action PushStack");
            ++repo_.scopeCount;
            Elem elem = new Elem();

            elem.type            = semi[0]; // expects type
            elem.name            = semi[1]; // expects name
            elem.beginLine       = repo_.semi.lineCount - 1;
            elem.endLine         = 0;
            elem.beginScopeCount = repo_.scopeCount;
            elem.endScopeCount   = 0;
            repo_.stack.push(elem);
            if (AAction.displayStack)
            {
                repo_.stack.display();
            }
            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi); // defined in abstract action
            }
            if (elem.type == "control" || elem.name == "anonymous")
            {
                return;
            }
            repo_.locations.Add(elem);
        }
示例#3
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Display.displayActions(actionDelegate, "action PushStack");
            ++repo_.scopeCount;
            Elem elem = new Elem();

            elem.type            = semi[0]; // expects type
            elem.name            = semi[1]; // expects name
            elem.beginLine       = repo_.semi.lineCount - 1;
            elem.endLine         = 0;
            elem.beginScopeCount = repo_.scopeCount;
            elem.endScopeCount   = 0;
            elem.cohesion        = 0;
            elem.coupling        = 0;

            //keep track of the current class and function scope
            if (elem.name != "anonymous")
            {
                if (elem.type.Equals("class") || elem.type.Equals("struct") || elem.type.Equals("interface"))
                {
                    repo_.currentClassScope = elem.name; //set the current class name
                }
                else if (elem.type.Equals("function"))
                {
                    repo_.currentFunctionScope = elem.name;
                }
            }

            repo_.stack.push(elem);

            if (AAction.displayStack)
            {
                repo_.stack.display();
            }
            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi); // defined in abstract action
            }
            if (elem.type == "control" || elem.name == "anonymous")
            {
                return;
            }
            repo_.locations.Add(elem);

            //update coupling base on class inhertiance on use
            if (semi.Contains("class") != -1)
            {
                inheritCoupling(semi);
            }
            else
            {
                userCoupling(semi);
            }
        }
示例#4
0
        public override void doAction(CSsemi.CSemiExp semi)
        {
            Display.displayActions(actionDelegate, "action SaveDeclar");
            Elem elem;

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

                //clear the function scope if we are exiting from it
                if (elem.name.Equals(repo_.currentFunctionScope))
                {
                    repo_.currentFunctionScope = "";
                }

                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
            {
                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
            }
        }
示例#5
0
        public override void doAction(ITokenCollection semi)
        {
            Display.displayActions(actionDelegate, "action SaveDeclar");
            Elem elem;

            try
            {
                // if stack is empty (shouldn't be) pop() will throw exception

                elem = repo_.stack.pop();

                // record ending line count and scope level

                for (var i = 0; i < repo_.locations.Count; ++i)
                {
                    var 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
            {
                return;
            }

            if (displaySemi)
            {
                var local = Factory.create();
                local.add(elem.type).add(elem.name);
                if (local[0] == "control")
                {
                    return;
                }

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

            try
            {
                elem = repo_.stack.pop();
                TypeInfo tempT = new TypeInfo();
                tempT.file = file_;
                extractType(elem);
                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
            {
                return;
            }

            if (AAction.displaySemi)
            {
                Lexer.ITokenCollection local = Factory.create();
                local.add(elem.type).add(elem.name);
                if (local[0] == "control")
                {
                    return;
                }

                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
            }
        }
        //Rule to detect delegates
        public override void doAction(ITokenCollection semi)
        {
            Display.displayActions(actionDelegate, "action PushStack");
            ++repo_.scopeCount;
            Elem elem = new Elem();

            elem.type            = semi[0];
            elem.name            = semi[1];
            elem.FileName        = repo_.FileName;
            elem.beginLine       = repo_.semi.lineCount() - 1;
            elem.endLine         = 0;
            elem.beginScopeCount = repo_.scopeCount;
            elem.endScopeCount   = 0;
            if (elem.type == "alias")
            {
                elem.aliasName = semi[2];
            }
            repo_.stack.push(elem);



            if (AAction.displayStack)
            {
                repo_.stack.display();
            }
            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount() - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi);
            }



            if (elem.type == "control" || elem.name == "anonymous")
            {
                return;
            }
            repo_.locations.Add(elem);
        }
 public override void doAction(ITokenCollection semi)
 {
   Display.displayActions(actionDelegate, "action SaveDeclar");
   Elem elem = new Elem();
   elem.type = semi[0];  // expects type
   elem.name = semi[1];  // expects name
   elem.beginLine = repo_.lineCount;
   elem.endLine = elem.beginLine;
   elem.beginScopeCount = repo_.scopeCount;
   elem.endScopeCount = elem.beginScopeCount;
   if (AAction.displaySemi)
   {
     Console.Write("\n  line# {0,-5}", repo_.lineCount - 1);
     Console.Write("entering ");
     string indent = new string(' ', 2 * repo_.stack.count);
     Console.Write("{0}", indent);
     this.display(semi); // defined in abstract action
   }
   repo_.locations.Add(elem);
 }
示例#9
0
        public override void doAction(ITokenCollection semi)
        {
            Display.displayActions(actionDelegate, "action SaveDeclar");
            var elem = new Elem();

            if (semi.size() == 3)               // type name ;
            {
                elem.type            = semi[0]; // expects type
                elem.name            = semi[1]; // expects name
                elem.file            = repo_.currentFile;
                elem.nameSpace       = repo_.currentNameSpace;
                elem.beginLine       = repo_.lineCount;
                elem.endLine         = elem.beginLine;
                elem.beginScopeCount = repo_.scopeCount;
                elem.endScopeCount   = elem.beginScopeCount;
            }

            if (semi.size() == 5)               // namespace . type name ;
            {
                elem.type            = semi[2]; // expects type
                elem.name            = semi[3]; // expects name
                elem.file            = repo_.currentFile;
                elem.nameSpace       = semi[0];
                elem.beginLine       = repo_.lineCount;
                elem.endLine         = elem.beginLine;
                elem.beginScopeCount = repo_.scopeCount;
                elem.endScopeCount   = elem.beginScopeCount;
            }

            if (!repo_.typeTable.contains(elem.type))
            {
                return;
            }
            var srcFile = repo_.typeTable.getFile(elem.type, elem.nameSpace);

            if (srcFile == "")
            {
                return;
            }
            repo_.dependencyTable.add(repo_.currentFile, srcFile);
        }
 public override void doAction(ITokenCollection semi)
 {
     Display.displayActions(actionDelegate, "action CollectAliases");
     repo_.addAlias(semi[1], semi[2]);
 }
示例#11
0
        public override void doAction(ITokenCollection semi)//IToken need more than get ss
        {
            Display.displayActions(actionDelegate, "action PushStack");
            ++repo_.scopeCount;//manage scope stack ss
            Elem elem = new Elem();


            elem.type = semi[0];     // expects type, i.e., namespace, class, struct, ..
            elem.name = semi[1];     // expects name

            //Checked if the type name matches with our requirement and added in Type Table
            string[] IncludeType = { "class", "enum", "struct", "delegate", "namespace", "interface", "using" };
            foreach (string stoken in IncludeType)
            {
                if (stoken == semi[0])
                {
                    String filename  = repo_.semi.getFileName();
                    String curr_file = System.IO.Path.GetFileName(filename);

                    if (semi[0].Equals("namespace"))//To create Type Table1q
                    {
                        holdnamespace = semi[1];
                        tt.add(semi[1], curr_file, semi[0]);
                    }
                    else if (semi[0].Equals("using"))//To create Alias Table
                    {
                        tt.addalias(semi[1], curr_file, semi[2]);
                        tt.addalias(semi[1], curr_file, semi[2]);
                    }
                    else
                    {
                        tt.add(semi[1], curr_file, holdnamespace);
                    }
                }
            }



            elem.beginLine       = repo_.semi.lineCount() - 1;
            elem.endLine         = 0; // will be set by PopStack action
            elem.beginScopeCount = repo_.scopeCount;
            elem.endScopeCount   = 0; // will be set by PopStack action
            repo_.stack.push(elem);

            // display processing details if requested

            if (AAction.displayStack)
            {
                repo_.stack.display();
            }
            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount() - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi); // defined in abstract action
            }

            // add starting location if namespace, type, or function

            if (elem.type == "control" || elem.name == "anonymous")//Never be controlled anonymous ss ni
            {
                return;
            }
            repo_.locations.Add(elem);
        }