LCOV - code coverage report
Current view: top level - src - ScriptAnaly.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 2 37 5.4 %
Date: 2010-12-13 Functions: 2 17 11.8 %
Branches: 2 38 5.3 %

           Branch data     Line data    Source code
       1                 :            : // $Id: ScriptAnaly.cc 6219 2008-10-01 05:39:07Z vern $
       2                 :            : //
       3                 :            : // See the file "COPYING" in the main distribution directory for copyright.
       4                 :            : 
       5                 :            : #include "Dict.h"
       6                 :            : #include "Expr.h"
       7                 :            : #include "Traverse.h"
       8                 :            : #include "ScriptAnaly.h"
       9                 :            : 
      10                 :            : typedef const char cchar;
      11 [ #  # ][ #  # ]:          0 : declare(PDict, cchar);
      12                 :            : 
      13                 :            : 
      14 [ #  # ][ #  # ]:          0 : class FindNoteCallback : public TraversalCallback {
      15                 :            : public:
      16                 :          0 :         FindNoteCallback()      { note_expr = 0; }
      17                 :            : 
      18                 :            :         virtual TraversalCode PreExpr(const Expr* e);
      19                 :            : 
      20                 :            :         Expr* note_expr;
      21                 :            : };
      22                 :            : 
      23                 :          0 : TraversalCode FindNoteCallback::PreExpr(const Expr* e)
      24                 :            :         {
      25         [ #  # ]:          0 :         if ( e->Tag() == EXPR_FIELD_ASSIGN )
      26                 :            :                 {
      27                 :            :                 const FieldAssignExpr* fae =
      28         [ #  # ]:          0 :                         dynamic_cast<const FieldAssignExpr*>(e);
      29                 :            : 
      30         [ #  # ]:          0 :                 if ( ! streq(fae->FieldName(), "note") )
      31                 :          0 :                         return TC_CONTINUE;
      32                 :            : 
      33                 :          0 :                 note_expr = fae->Op();
      34                 :          0 :                 return TC_ABORTALL;
      35                 :            :                 }
      36                 :            : 
      37                 :          0 :         return TC_CONTINUE;
      38                 :            :         }
      39                 :            : 
      40                 :            : 
      41 [ #  # ][ #  # ]:          0 : class NoticeCallback : public TraversalCallback {
      42                 :            : public:
      43                 :            :         virtual TraversalCode PreExpr(const Expr* e);
      44                 :            : 
      45                 :            :         PDict(cchar) notices;
      46                 :            : };
      47                 :            : 
      48                 :          0 : TraversalCode NoticeCallback::PreExpr(const Expr* e)
      49                 :            :         {
      50         [ #  # ]:          0 :         if ( e->Tag() != EXPR_CALL )
      51                 :          0 :                 return TC_CONTINUE;
      52                 :            : 
      53         [ #  # ]:          0 :         const CallExpr* ce = dynamic_cast<const CallExpr*>(e);
      54                 :            : 
      55 [ #  # ][ #  # ]:          0 :         if ( ce->Func()->Tag() != EXPR_NAME ||
                 [ #  # ]
      56                 :            :              ! streq(((NameExpr*) ce->Func())->Id()->Name(), "NOTICE") )
      57                 :          0 :                 return TC_CONTINUE;
      58                 :            : 
      59                 :          0 :         FindNoteCallback fnc;
      60                 :          0 :         ce->Traverse(&fnc);
      61         [ #  # ]:          0 :         if ( fnc.note_expr )
      62                 :            :                 {
      63                 :          0 :                 ODesc d;
      64                 :          0 :                 fnc.note_expr->Describe(&d);
      65         [ #  # ]:          0 :                 if ( ! notices.Lookup(d.Description()) )
      66                 :            :                         {
      67                 :          0 :                         const char* desc = strdup(d.Description());
      68                 :          0 :                         notices.Insert(desc, desc);
      69                 :          0 :                         }
      70                 :            :                 }
      71                 :            : 
      72                 :          0 :         return TC_CONTINUE;
      73                 :            :         }
      74                 :            : 
      75                 :            : 
      76                 :          0 : void notice_analysis()
      77                 :            :         {
      78                 :          0 :         NoticeCallback cb;
      79                 :          0 :         traverse_all(&cb);
      80                 :            : 
      81                 :          0 :         const cchar* notice = 0;
      82                 :          0 :         IterCookie* iter = cb.notices.InitForIteration();
      83                 :            : 
      84         [ #  # ]:          0 :         while ( (notice = cb.notices.NextEntry(iter)) )
      85                 :          0 :                 printf("Found NOTICE: %s\n", notice);
      86 [ +  - ][ +  - ]:          6 :         }

Generated by: LCOV version 1.8