~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to AspectC++/PointCutContext.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
// MA  02111-1307  USA                                            
18
18
 
19
19
#include "PointCutContext.h"
20
 
#include "TrackerDog.h"
21
20
#include "JoinPoint.h"
22
21
#include "IntroductionUnit.h"
 
22
#include "TransformInfo.h"
23
23
 
24
24
#include "Puma/ErrorStream.h"
25
25
#include "Puma/CFunctionInfo.h"
30
30
#include "Puma/CTree.h"
31
31
#include "Puma/Filter.h"
32
32
 
33
 
void PointCutContext::setup(CTranslationUnit& tunit) {
34
 
  scopes (tunit);
35
 
  TrackerDog tracker (tunit, _world);
36
 
  tracker.run ();
37
 
}
38
 
 
39
 
void PointCutContext::scopes (CTranslationUnit& tunit) {
40
 
  CClassDatabase &db = tunit.db ();
41
 
 
42
 
  for (unsigned int c = 0; c < db.ClassInfos (); c++) {
43
 
    CClassInfo *ci = db.ClassInfo (c);
44
 
 
45
 
    // Don't consider
46
 
    // * anonymous classes like template instances(?)
47
 
    // * the generated class JoinPoint
48
 
    // * classes defined in the special namespace AC
49
 
    if (strncmp (ci->Name (), "%", 1) == 0 ||
50
 
        strcmp (ci->QualName (), "JoinPoint") == 0 ||
51
 
        strncmp (ci->QualName (), "AC::", 4) == 0)
52
 
      continue;
53
 
 
54
 
    // Templates and classes nested in template class are not considered for
55
 
    // matching, only instances
56
 
    CObjectInfo *oi = ci;
57
 
    bool in_template = false;
58
 
    do {
59
 
      assert (oi->ClassInfo ());
60
 
      if (oi->ClassInfo ()->insideTemplate ()) {
61
 
        in_template = true;
62
 
        break;
63
 
      }
64
 
      oi = oi->NextObject ();
65
 
    } while (oi != ci);
66
 
    if (in_template)
67
 
      continue;
68
 
      
69
 
    ci = (CClassInfo*)TrackerDog::unique_object (ci);
70
 
    if (ci) {
71
 
      ACAspectInfo *ai = db.AspectInfo (ci);
72
 
      if (ai)
73
 
        _world.new_aspect (ai);
74
 
      else
75
 
        _world.new_class (ci);
76
 
    }
77
 
  }
78
 
 
79
 
  for (unsigned f = 0; f < db.FunctionInfos (); f++) {
80
 
    CFunctionInfo *fi = db.FunctionInfo (f);
81
 
    fi = TrackerDog::filter_func (fi);
82
 
    if (!fi)
83
 
      continue;
84
 
    fi = (CFunctionInfo*)TrackerDog::unique_object (fi);
85
 
    if (fi)
86
 
      _world.new_function (fi);
87
 
  }
88
 
}
89
 
 
90
33
CFunctionInfo *PointCutContext::lookup_pointcut(ACAspectInfo *ai,
91
34
                                                CFunctionInfo *fi) {
92
35
  CFunctionInfo *result = 0;
154
97
  // the class where the referenced pointcut is located in ...
155
98
  CClassInfo *ref_class = func->ClassScope ()->ClassInfo ();
156
99
 
 
100
  ACAspectInfo *ai = TI_Aspect::of (*_aspect)->aspect_info ();
157
101
  // if the pointcut is declared virtual, find the real definition
158
 
  if (ref_class != _aspect->ClassInfo () && func->isVirtual ()) {
159
 
    result = lookup_pointcut (_aspect, func);
 
102
  if (ref_class != ai->ClassInfo () && func->isVirtual ()) {
 
103
    result = lookup_pointcut (ai, func);
160
104
    if (!result)
161
105
      result = func;
162
106
  }