Exemplo n.º 1
0
        public functionCallCounter copy()
        {
            functionCallCounter fcc = new functionCallCounter(this);

            fcc.count = this.count;
            return(fcc);
        }
Exemplo n.º 2
0
 public void setAllfreqUsedFuncCalls()
 {
     foreach (var item in frequentlyUsedFunctionCalls)
     {
         foreach (functionCallCounter t in item.functionCalls)
         {
             functionCallCounter t2 = allFrequentlyUsedFunctionCalls.Find(a => a.getLexeme() == t.getLexeme());
             t2.setCount(t2.getCount() + t.getCount());
         }
     }
 }
Exemplo n.º 3
0
 public void setAllCodeFuncCalls()
 {
     foreach (var item in codeFunctionCalls)
     {
         foreach (functionCallCounter t in item.functionCalls)
         {
             if (allCodeFunctionCalls.Select(a => a.getLexeme()).Contains(t.getLexeme()))
             {
                 functionCallCounter t2 = allCodeFunctionCalls.Find(a => a.getLexeme() == t.getLexeme());
                 t2.setCount(t2.getCount() + t.getCount());
             }
             else
             {
                 allCodeFunctionCalls.Add(t.copy());
             }
         }
     }
 }
Exemplo n.º 4
0
        public void findIdentifiers()
        {
            //  code.structAsDatatype(this.tokens);
            for (int i = 0; i < tokens.Count - 1; i++)
            {
                if ((tokens[i].isIdentifierTokenObject()) && (tokens[i + 1].getLexeme() == "("))
                {
                    functionCallCounter fc = new functionCallCounter(tokens[i]);
                    tokens[i] = fc;
                    for (int q = 0; q < holeCodeTokens.Count; q++)
                    {
                        if (holeCodeTokens[q].id == tokens[i].id)
                        {
                            holeCodeTokens[q] = fc;
                        }
                    }
                }
            }

            for (int i = 0; i < tokens.Count; i++)
            {
                bool pointer = (upperLevelPointers.Concat(thisScopePointers).ToList().Select(a => a.getLexeme()).ToList()).Contains(tokens[i].getLexeme());
                bool array   = upperLevelArray.Concat(thisScopeArray).ToList().Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme());
                if (((tokens[i].isPointer) || pointer))
                {
                    if ((i > 0) && tokens[i].isPointer && ((tokens[i - 1].isDatatype() || (tokens[i - 1].getLexeme() == ","))))
                    {
                        pointer p = (pointer)tokens[i];

                        if (tokens[i - 1].isDatatype())
                        {
                            p.dataType = tokens[i - 1];
                        }
                        else if (tokens[i - 1].getLexeme() == ",")
                        {
                            int k = i - 1;
                            while ((k > 0) && (!tokens[k].isDatatype()))
                            {
                                k--;
                            }
                            if (k != 0)
                            {
                                p.dataType = tokens[k];
                            }
                        }
                        thisScopePointers.Add(p);
                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = p;
                            }
                        }

                        tokens[i] = p;
                    }
                    else if (thisScopePointers.Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme()))
                    {
                        pointer id;
                        id = thisScopePointers.Find(a => a.getLexeme() == tokens[i].getLexeme());

                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    else if (upperLevelPointers.Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme()))
                    {
                        pointer id;
                        id = upperLevelPointers.Find(a => a.getLexeme() == tokens[i].getLexeme());

                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    continue;
                }
                if ((i > 0) && ((tokens[i].isArray) || array))
                {
                    if ((i > 0) && tokens[i].isPointer && (tokens[i - 1].isDatatype()))
                    {
                        array p = (array)tokens[i];
                        if (tokens[i - 1].isDatatype())
                        {
                            p.dataType = tokens[i - 1];
                        }
                        else if (tokens[i - 1].getLexeme() == ",")
                        {
                            int k = i - 1;
                            while ((k > 0) && (!tokens[k].isDatatype()))
                            {
                                k--;
                            }
                            if (k != 0)
                            {
                                p.dataType = tokens[k];
                            }
                        }
                        thisScopeArray.Add(p);
                    }
                    else if (thisScopeArray.Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme()))
                    {
                        array id;
                        id = thisScopeArray.Find(a => a.getLexeme() == tokens[i].getLexeme());

                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    else if (upperLevelArray.Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme()))
                    {
                        array id;
                        id = upperLevelArray.Find(a => a.getLexeme() == tokens[i].getLexeme());

                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    continue;
                }
                if ((tokens[i].isIdentifierTokenObject()) && !tokens[i].isPointer && !tokens[i].isArray && !array && !pointer)
                {
                    identifier id;
                    if ((i > 0) && tokens[i].isIdentifierTokenObject() && ((tokens[i - 1].isDatatype() || tokens[i - 1].getLexeme() == ",")))
                    {
                        id = new identifier(tokens[i]);
                        if ((i > 0) && (tokens[i - 1].isDatatype()))
                        {
                            id.dataType = tokens[i - 1];
                        }
                        else if (tokens[i - 1].getLexeme() == ",")
                        {
                            int k = i - 1;
                            while ((k > 0) && (!tokens[k].isDatatype()))
                            {
                                k--;
                            }
                            if (k != 0)
                            {
                                id.dataType = tokens[k];
                            }
                        }
                        thisScopeVars.Add(id);

                        //for (int q = 0; q < thisCodeToken.Count; q++)
                        //    if (thisCodeToken[q].id == globalScobeTokens[i].id)
                        //        thisCodeToken[q] = id;

                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }

                        tokens[i] = id;
                    }
                    else if (thisScopeVars.Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme()))
                    {
                        id = thisScopeVars.Find(a => a.getLexeme() == tokens[i].getLexeme());

                        //for (int q = 0; q < thisCodeToken.Count; q++)
                        //    if (thisCodeToken[q].id == globalScobeTokens[i].id)
                        //        thisCodeToken[q] = id;
                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    else if (upperLevelVar.Select(a => a.getLexeme()).ToList().Contains(tokens[i].getLexeme()))
                    {
                        id = upperLevelVar.Find(a => a.getLexeme() == tokens[i].getLexeme());
                        //for (int q = 0; q < thisCodeToken.Count; q++)
                        //    if (thisCodeToken[q].id == globalScobeTokens[i].id)
                        //        thisCodeToken[q] = id;
                        for (int q = 0; (holeCodeTokens != null) && (q < holeCodeTokens.Count); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    else
                    {
                        id = new identifier(tokens[i]);
                        if ((i > 0) && (tokens[i - 1].isDatatype()))
                        {
                            id.dataType = tokens[i - 1];
                        }
                        thisScopeVars.Add(id);
                        //for (int q = 0; q < thisCodeToken.Count; q++)
                        //    if (thisCodeToken[q].id == globalScobeTokens[i].id)
                        //        thisCodeToken[q] = id;
                        for (int q = 0; (q < holeCodeTokens.Count) && (holeCodeTokens != null); q++)
                        {
                            if (holeCodeTokens[q].id == tokens[i].id)
                            {
                                holeCodeTokens[q] = id;
                            }
                        }
                        tokens[i] = id;
                    }
                    continue;
                }
            }
        }
Exemplo n.º 5
0
 public ComparisonTable(functionCallCounter congruentFunctionCallCounterCounter, int firstScopeId, int secondScopeId)
 {
     CongruentFunctionCallCounterCounter = congruentFunctionCallCounterCounter;
     FirstScopeId  = firstScopeId;
     SecondScopeId = secondScopeId;
 }