19
19
#ifndef __IntroductionInfo_h__
20
20
#define __IntroductionInfo_h__
22
#include "Puma/Array.h"
23
#include "Puma/Printable.h"
24
#include "Puma/ACTree.h"
25
#include "Puma/CProtection.h"
26
#include "Puma/Unit.h"
26
#include "JoinPointLoc.h"
27
#include "BackEndProblems.h"
28
#include "PointCutEvaluator.h"
29
#include "PointCutContext.h"
30
#include "JoinPointModel.h"
31
#include "TransformInfo.h"
28
32
using namespace Puma;
31
class ACIntroductionInfo;
38
34
class IntroductionInfo {
38
JPL_Introduction &_intro;
40
enum intro_type { INTRO_BASECLASS, INTRO_INHERITED, INTRO_OTHER,
41
INTRO_SLICE_REF, INTRO_SLICE_DECL, INTRO_ERROR };
45
ACIntroductionInfo *_acii;
48
CProtection::Type _prot;
49
Array<CObjectInfo*> _objs;
54
IntroductionInfo (AspectInfo *ai, ACIntroductionInfo *acii);
55
ACIntroductionInfo *ac_info () const { return _acii; }
56
void print (ostream& os) const;
57
CObjectInfo *object (int i) const { return _objs.lookup (i); }
58
int objects () const { return _objs.length (); }
59
intro_type type () const { return _type; }
60
const char *type_str () const {
62
case INTRO_BASECLASS: return "baseclass";
63
case INTRO_INHERITED: return "inherited";
64
case INTRO_OTHER: return "intro";
65
case INTRO_SLICE_REF: return "slice ref";
66
case INTRO_SLICE_DECL: return "slice decl";
67
case INTRO_ERROR: return "error"; // Hm, shouldn't happen
69
return "error"; // just to suppress warnings
71
int line () const { return _tree->token ()->location ().line (); }
73
return _tree->end_token ()->location ().line () -
76
const Unit &unit () const {
77
return *(Unit*)_tree->token ()->belonging_to ();
79
CT_AdviceDecl *tree () const { return _tree; }
80
CProtection::Type prot () const { return _prot; }
81
AspectInfo *aspect () { return _aspect; }
82
const Unit &pattern () const { return _pattern; }
42
IntroductionInfo (JPL_Aspect &a, JPL_Introduction &i) :
43
_aspect (a), _intro (i), _pce (0) {}
44
~IntroductionInfo () {
45
if (_pce) PointCutEvaluator::destroy (_pce);
47
JPL_Aspect &aspect () const { return _aspect; }
48
PointCut &pointcut () { return _pointcut; }
49
JPL_Introduction &intro () const { return _intro; }
50
PointCutExpr *expr () const { return _pce; }
51
void analyze_expr (ErrorStream &err, JoinPointModel &jpm) {
52
PointCutContext context (jpm);
53
PointCutEvaluator eval (err, context);
54
context.concrete_aspect (_aspect);
55
_pce = eval.create (_intro.expr (), JoinPointLoc::Name);
85
59
#endif // __IntroductionInfo_h__