19
19
#ifndef __join_point_loc_h__
20
20
#define __join_point_loc_h__
33
#include "Puma/Signature.h"
34
#include "Puma/DString.h"
35
#include "Puma/CRecord.h"
36
#include "Puma/CAttributeInfo.h"
37
#include "Puma/CClassInfo.h"
38
#include "Puma/ACAspectInfo.h"
39
#include "Puma/CFunctionInfo.h"
40
#include "Puma/CTree.h"
41
#include "Puma/Filter.h"
44
#include "MatchName.h"
33
#include "Puma/Unit.h"
35
#include "MatchExpr.h"
36
#include "SourceLoc.h"
37
#include "RepoXMLNode.h"
38
#include "JoinPointModelElement.h"
41
class CTree; // pointcuts are currently represented as a CTree
44
class ModelTransformInfo {
46
virtual ~ModelTransformInfo () {}
51
48
class JoinPointPlan;
51
// forward declaration (for cyclic relations)
54
class JPL_Introduction;
59
* \brief the common base class of all join point location types
61
* The class contains elements to store join point locations in a hierarchical
62
* structure, associated source locations, etc.
63
* In order to associate a weaving plan and parser-specific syntax information
64
* two (almost) untyped pointers are included. They can be used by higher
68
class JoinPointLoc : public JoinPointModelElement {
56
70
enum join_point_type {
58
FieldReference = 0x0001,
59
FieldAssignment = 0x0002,
62
Construction = 0x0010,
72
FieldReference = 0x000001,
73
FieldAssignment = 0x000002,
74
MethodCall = 0x000004,
76
Construction = 0x000010,
77
Destruction = 0x000020,
84
AdviceCode = 0x002000,
85
ClassSlice = 0x004000,
88
Introduction = 0x008000,
75
string _sig; // the signature of this jp as a string
76
int _lid; // local id for this jp inside the current function
77
JoinPointPlan *_plan; // the weaving plan for advised jps
78
int _id; // a unique id for each joinpoint location
80
void signature (ostream &, CFunctionInfo *func_info);
81
void signature (ostream &, CAttributeInfo *func_info);
82
void signature (ostream &, CTypeInfo *type_info);
95
/// parent in the hierarchical join point model structure
97
/// source code location(s) of this join point (shadow)
98
set<SourceLoc> _source_locs;
99
/// the signature of this jp as a string
101
/// the weaving plan for advised jps
102
JoinPointPlan *_plan;
103
/// parser-provided info for code transformation
104
ModelTransformInfo *_trans;
105
/// translation units in which this element was detected
86
JoinPointLoc () : _lid (0), _plan (0), _id (-1) {}
87
virtual ~JoinPointLoc () {}
89
const char *signature () { return _sig.c_str (); }
90
int lid () const { return _lid; }
110
JoinPointLoc () : _parent (0), _plan (0), _trans (0) {}
111
JoinPointLoc (const JoinPointLoc &jpl) : _parent (0), _plan (0), _trans (0) {
114
JoinPointLoc (RepoXMLNode jn, RepoXMLNode::iter &curr);
115
virtual ~JoinPointLoc () { if (_trans) delete _trans; }
117
void parent (JPL_Name *p);
118
JPL_Name *parent () const { return _parent; }
120
const IdSet &tunits () const { return _tunits; }
121
IdSet &tunits () { return _tunits; }
122
virtual const char *signature () const { return _sig.c_str (); }
123
string filename () const;
125
typedef const set<SourceLoc> SSet;
126
const set<SourceLoc> &source_locs () const { return _source_locs; }
127
set<SourceLoc> &source_locs () { return _source_locs; }
128
void source_loc (const SourceLoc &sl) { _source_locs.insert (sl); }
91
129
JoinPointPlan *plan () const { return _plan; }
92
130
void plan (JoinPointPlan *p) { _plan = p; }
96
int id () const { return _id; }
97
void id (int new_id) { _id = new_id; }
131
ModelTransformInfo *transform_info () const { return _trans; }
132
void transform_info (ModelTransformInfo *trans) { _trans = trans; }
99
virtual join_point_type type () { return None; }
134
virtual join_point_type type () const { return None; }
100
135
virtual const char *type_str () const { return (const char*)0; }
101
virtual CTree *tree () const { return 0; }
102
virtual CObjectInfo *assoc_obj () { return 0; }
103
virtual Token *insertloc_tjp_struct() { return 0; }
104
virtual Token *insertloc_before () { return 0; }
105
virtual Token *insertloc_after () { return 0; }
106
virtual CFunctionInfo *tjp_type() {return 0;}
107
virtual CFunctionInfo *tjp_target() {return 0;}
108
virtual CFunctionInfo *tjp_that() {return 0;}
109
virtual CFunctionInfo *action_dst_func() {return 0;}
110
virtual CFunctionInfo *action_src_func() {return 0;}
137
bool operator == (const JoinPointLoc &right) const {
138
return type () == right.type () && _sig == right._sig;
140
bool operator != (const JoinPointLoc &right) const {
141
return !(*this == right);
144
virtual void dump (int indent = 0) const;
146
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
148
/// create a join point loc tree from an XML document subtree
149
static JoinPointLoc *create (RepoXMLNode node);
150
static IdElementMap *_map;
152
/// check whether this join point is seen by a specific tranlation unit
153
virtual bool is_known_in_tunit (File *tunit);
156
class JPL_Type : public JoinPointLoc {
158
mutable MatchSignature _match_sig; // calculated on demand
159
void parse_match_signature () const {
161
ErrorStream e (cerr);
162
_match_sig.parse (e, l, signature ());
165
JPL_Type (const string &sig) { _sig = sig; }
166
join_point_type type () const { return Type; }
167
virtual const char *type_str () const { return "type"; }
168
const MatchSignature &match_signature () const {
169
if (_match_sig.is_new ())
170
parse_match_signature ();
113
175
class JPL_Name : public JoinPointLoc {
117
JPL_Name (CTypeInfo *t) : _ctype (t) {}
118
virtual ~JPL_Name () {}
121
CTypeInfo *type_info () const { return _ctype; }
122
virtual CObjectInfo *obj_info () = 0;
177
typedef list<const JoinPointLoc*> CList;
180
typedef std::map<string, JPL_Name*> NameMap;
187
mutable MatchSignature _match_sig; // calculated on demand
188
virtual void parse_match_signature () const {
189
Location l ("<no filename>", 0);
190
ErrorStream e (cerr);
191
_match_sig.parse (e, l, signature ());
195
JPL_Name () : _is_built_in (false) {}
196
JPL_Name (const JPL_Name &jpl) : JoinPointLoc (jpl), _name (jpl._name),
197
_is_built_in (jpl._is_built_in) {}
198
JPL_Name (RepoXMLNode node, RepoXMLNode::iter &curr);
199
const CList &children () const { return _children; }
200
void add_child (JoinPointLoc *child) {
201
_children.push_back (child);
202
if (child->type () & JoinPointLoc::Name) {
203
_name_map.insert (NameMap::value_type (child->signature (),
207
void remove_child (const JoinPointLoc *child) {
208
_children.remove (child);
209
_name_map.erase (child->signature ());
211
void name (const string &name) { _name = name; }
212
const string &name () const { return _name; }
213
virtual void dump (int indent = 0) const;
214
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
215
bool is_root () const { return _sig == "::"; }
216
bool is_built_in () const { return _is_built_in; }
217
void is_built_in (bool b) { _is_built_in = b; }
218
const MatchSignature &match_signature () const {
219
if (_match_sig.is_new ())
220
parse_match_signature ();
223
JPL_Name *lookup (const string &name) {
224
NameMap::const_iterator i = _name_map.find (name);
225
return (i == _name_map.end ()) ? 0 : i->second;
229
class JPL_Namespace : public JPL_Name {
231
JPL_Namespace (const string &name) { _sig = name; }
232
JPL_Namespace (const JPL_Namespace &jpl) : JPL_Name (jpl) {}
233
JPL_Namespace (RepoXMLNode node, RepoXMLNode::iter &curr);
234
join_point_type type () const { return Namespace; }
235
virtual const char *type_str () const { return "namespace"; }
125
238
class JPL_Class : public JPL_Name {
126
CClassInfo *class_obj;
127
CObjectInfo *link_once_object (CClassInfo *);
241
set<int> _derived_ids;
130
JPL_Class (CClassInfo *c);
131
CClassInfo *class_info () { return class_obj; }
132
virtual CObjectInfo *obj_info () { return class_obj; }
133
join_point_type type () { return Class; }
245
JPL_Class (const string &name) { _sig = name; }
246
JPL_Class (const JPL_Class &jpl) : JPL_Name (jpl), _intro_target (jpl._intro_target) {}
247
JPL_Class (RepoXMLNode node, RepoXMLNode::iter &curr);
248
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
250
join_point_type type () const { return Class; }
134
251
virtual const char *type_str () const { return "class"; }
135
virtual CTree *tree () const;
136
// find a member that is/must be link-once (global) code
137
CObjectInfo *link_once_object () { return link_once_object (class_obj); }
252
void intro_target (bool i) { _intro_target = i; }
253
bool intro_target () const { return _intro_target; }
255
// get the list of base classes (IDs) => can be mapped with 'map'
256
const set<int> &base_class_ids () const { return _base_ids; }
258
// get the list of derived classes (IDs) => can be mapped with 'map'
259
const set<int> &derived_class_ids () const { return _derived_ids; }
261
// declare a class to be a base class of this class
262
void base (JPL_Class *base) {
263
_base_ids.insert (base->id ());
264
base->_derived_ids.insert (id ());
267
// generate back links
268
void generate_back_links () {
269
for (set<int>::const_iterator i = _base_ids.begin ();
270
i != _base_ids.end (); ++i)
271
((JPL_Class*)map (*i))->_derived_ids.insert (id ());
140
275
class JPL_Aspect : public JPL_Class {
141
ACAspectInfo *aspect_obj;
276
list<JPL_AdviceCode*> _advice_codes;
277
list<JPL_Introduction*> _intro_infos;
278
list<JPL_Order*> _order_infos;
143
JPL_Aspect (ACAspectInfo *a) : JPL_Class (a->ClassInfo ()), aspect_obj (a) {}
144
ACAspectInfo *aspect_info () const { return aspect_obj; }
145
virtual join_point_type type () { return Aspect; }
281
JPL_Aspect (const string &name) : JPL_Class (name) {}
282
JPL_Aspect (const JPL_Aspect &jpl) : JPL_Class (jpl) {}
283
JPL_Aspect (RepoXMLNode node, RepoXMLNode::iter &curr) :
284
JPL_Class (node, curr) {}
285
virtual join_point_type type () const { return Aspect; }
146
286
virtual const char *type_str () const { return "aspect"; }
288
/// the list of associated code advice nodes
289
list<JPL_AdviceCode*> &advice_codes () { return _advice_codes; }
291
/// the list of associated order advice nodes
292
list<JPL_Order*> &order_infos () { return _order_infos; }
294
/// the list of associated introduction nodes
295
list<JPL_Introduction*> &intro_infos () { return _intro_infos; }
297
/// collect the advice codes from this aspect and all base aspects
298
void collect_advice_codes (list<JPL_AdviceCode*> &codes) const {
299
for (list<JPL_AdviceCode*>::const_iterator i = _advice_codes.begin ();
300
i != _advice_codes.end (); ++i)
301
codes.push_back (*i);
302
const set<int> &bases = base_class_ids ();
303
for (set<int>::const_iterator i = bases.begin (); i != bases.end (); ++i) {
304
JPL_Class *cls = (JPL_Class*)map (*i);
305
if (cls->type () == JoinPointLoc::Aspect)
306
((JPL_Aspect*)cls)->collect_advice_codes (codes);
310
/// collect the advice codes from this aspect and all base aspects
311
void collect_intros (list<JPL_Introduction*> &intros) const {
312
for (list<JPL_Introduction*>::const_iterator i = _intro_infos.begin ();
313
i != _intro_infos.end (); ++i)
314
intros.push_back (*i);
315
const set<int> &bases = base_class_ids ();
316
for (set<int>::const_iterator i = bases.begin (); i != bases.end (); ++i) {
317
JPL_Class *cls = (JPL_Class*)map (*i);
318
if (cls->type () == JoinPointLoc::Aspect)
319
((JPL_Aspect*)cls)->collect_intros (intros);
323
/// collect the advice codes from this aspect and all base aspects
324
void collect_orders (list<JPL_Order*> &orders) const {
325
for (list<JPL_Order*>::const_iterator i = _order_infos.begin ();
326
i != _order_infos.end (); ++i)
327
orders.push_back (*i);
328
const set<int> &bases = base_class_ids ();
329
for (set<int>::const_iterator i = bases.begin (); i != bases.end (); ++i) {
330
JPL_Class *cls = (JPL_Class*)map (*i);
331
if (cls->type () == JoinPointLoc::Aspect)
332
((JPL_Aspect*)cls)->collect_orders (orders);
149
337
class JPL_Function : public JPL_Name {
150
CFunctionInfo *func_obj;
152
JPL_Function (CFunctionInfo *f);
153
CFunctionInfo *func_info () { return func_obj; }
154
virtual CObjectInfo *obj_info () { return func_obj; }
155
join_point_type type () { return Function; }
340
NON_MEMBER, STATIC_MEMBER, MEMBER, VIRTUAL_MEMBER, CONSTRUCTOR, DESTRUCTOR,
345
FunctionType _function_type;
346
vector<JPL_Type *> _arg_types;
347
JPL_Type *_result_type;
350
virtual void parse_match_signature () const {
351
JPL_Name::parse_match_signature ();
353
_match_sig.declare_virtual_function ();
357
JPL_Function (const string &n, const string &s) :
358
_function_type (UNKNOWN), _result_type (0) {
361
JPL_Function (const JPL_Function &jpl) :
362
JPL_Name (jpl), _function_type (jpl._function_type) {}
363
JPL_Function (RepoXMLNode node, RepoXMLNode::iter &curr);
366
// set the function type
367
void function_type (FunctionType ft) { _function_type = ft; }
369
// helper functions to check the function type
370
bool is_non_member () const { return _function_type == NON_MEMBER; }
371
bool is_static_member () const { return _function_type == STATIC_MEMBER; }
372
bool is_non_static_member () const { return _function_type == MEMBER ||
373
_function_type == VIRTUAL_MEMBER; }
374
bool is_virtual () const { return _function_type == VIRTUAL_MEMBER; }
375
bool is_constructor () const { return _function_type == CONSTRUCTOR; }
376
bool is_destructor () const { return _function_type == DESTRUCTOR; }
379
int arg_count () const {
380
return (int)_arg_types.size ();
382
const JPL_Type &arg_type (int i) const {
383
assert (i >= 0 && i < arg_count ());
384
return *_arg_types[i];
386
void add_arg_type (JPL_Type *type) { _arg_types.push_back (type); }
387
void reset_types () {
388
for (int i = 0; i < arg_count (); i++)
389
delete _arg_types[i];
397
// manage the result type
398
void result_type (JPL_Type *type) {
399
if (_result_type) delete _result_type;
402
const JPL_Type &result_type () const { return *_result_type; }
404
join_point_type type () const { return Function; }
156
405
virtual const char *type_str () const { return "function"; }
157
virtual CTree *tree () const;
160
class JPL_Type : public JPL_Name {
162
JPL_Type (CTypeInfo *t);
163
virtual CObjectInfo *obj_info () { return 0; }
164
join_point_type type () { return Type; }
165
virtual const char *type_str () const { return "type"; }
166
virtual CTree *tree () const;
406
bool has_same_name_and_args (const JPL_Function &func) const;
409
class JPL_ClassSlice : public JPL_Name {
411
enum class_slice_type { CS_OLD_BASE, CS_OLD_OTHER, CS_NORMAL, CS_ERROR };
414
class_slice_type _type;
415
CProtection::Type _prot;
419
JPL_ClassSlice (const string &name) :
420
_type (CS_NORMAL), _prot (CProtection::PROT_PRIVATE) {
423
JPL_ClassSlice (RepoXMLNode node, RepoXMLNode::iter &curr);
424
JPL_ClassSlice (const JPL_ClassSlice &jpl) : _type (jpl._type),
425
_prot (jpl._prot), _pattern (jpl._pattern) {}
426
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
428
void slice_type (class_slice_type t) { _type = t; }
429
class_slice_type slice_type () const { return _type; }
430
void prot (CProtection::Type p) { _prot = p; }
431
CProtection::Type prot () const { return _prot; }
432
const Unit &pattern () const { return _pattern; }
433
Unit &pattern () { return _pattern; }
434
virtual join_point_type type () const { return ClassSlice; }
435
virtual const char *type_str () const {
437
case CS_OLD_BASE: return "slice-dep-base";
438
case CS_OLD_OTHER: return "slice-dep-member";
439
case CS_NORMAL: return "slice-class";
440
default: return "error";
447
* \brief the common base class of all code join-point locations
170
450
class JPL_Code : public JoinPointLoc {
171
vector<JPL_Type *> _arg_types;
172
JPL_Type *_result_type;
452
/// local id for this jp inside the current function (or -1)
174
JPL_Code () : _result_type (0) {}
455
JPL_Code () : _lid (0) {}
456
JPL_Code (const JPL_Code &jpl) : JoinPointLoc (jpl), _lid (jpl._lid) {}
457
JPL_Code (RepoXMLNode node, RepoXMLNode::iter &curr) :
458
JoinPointLoc (node, curr), _lid (0) {}
177
460
virtual bool is_pseudo () const { return false; }
462
// get the local id within the current function
463
int lid () const { return _lid; }
465
// set the local id within the current function
466
void lid (int lid) { _lid = lid; }
468
// the lexical scope of this code join point as needed by 'within'
469
virtual JPL_Name *lexical_scope () const = 0;
179
471
// argument handling
180
int arg_count () const {
181
return (int)_arg_types.size ();
183
const JPL_Type &arg_type (int i) const {
184
assert (i >= 0 && i < arg_count ());
185
return *_arg_types[i];
187
void add_arg_type (CTypeInfo *ctype) {
188
_arg_types.push_back (new JPL_Type (ctype));
472
virtual int arg_count () const = 0;
473
virtual const JPL_Type &arg_type (int i) const = 0;
191
475
// manage the result type
192
void result_type (CTypeInfo *ctype) { _result_type = new JPL_Type (ctype); }
193
const JPL_Type &result_type () const { return *_result_type; }
195
// That and Target types for the JoinPoint-API
196
virtual CTypeInfo *that_type () = 0;
197
virtual CTypeInfo *target_type () const = 0;
199
// helper functions for derived class
200
CTypeInfo *get_that_type (CObjectInfo *obj);
202
// generates the signature of a wrapper function for exec/cons/dest join pts
203
string wrapper_function_signature (CFunctionInfo *func, bool def);
476
virtual const JPL_Type &result_type () const = 0;
205
478
// interface needed to generate proper proceed code
206
479
virtual bool proceed_needs_args () const {
207
480
return arg_count () > 0;
209
482
virtual bool proceed_needs_result () const {
210
return _result_type && !_result_type->type_info ()->is_void ();
212
virtual bool proceed_needs_target () const { return false; }
213
virtual bool proceed_needs_that () const { return false; }
214
virtual bool proceed_needs_fptr () const { return false; }
216
// helper function: check if a function is a method (needs a 'this' pointer)
217
static bool needs_this (CFunctionInfo *func) {
218
if (func->isMethod () && !func->isStaticMethod ()) {
219
return !(func->isOperator () &&
220
(strcmp (func->Name (), "operator new") == 0 ||
221
strcmp (func->Name (), "operator new[]") == 0 ||
222
strcmp (func->Name (), "operator delete") == 0 ||
223
strcmp (func->Name (), "operator delete[]") == 0));
483
return result_type () != JPL_Type ("void");
487
class JPL_Method : public JPL_Code {
489
JPL_Method () { _lid = -1; }
490
JPL_Method (const JPL_Method &jpl) : JPL_Code (jpl) {}
491
JPL_Method (RepoXMLNode node, RepoXMLNode::iter &curr) :
492
JPL_Code (node, curr) {}
493
join_point_type type () const { return Method; }
494
virtual const char *type_str () const { return "exec"; }
497
virtual int arg_count () const { return function ()->arg_count (); }
498
virtual const JPL_Type &arg_type (int i) const { return function ()->arg_type (i); }
500
// manage the result type
501
const JPL_Type &result_type () const { return function ()->result_type (); }
503
// the lexical scope of this code join point as needed by 'within'
504
virtual JPL_Name *lexical_scope () const { return (JPL_Name*)parent ()->parent (); }
506
// the executed function
507
JPL_Function *function () const { return (JPL_Function*)parent (); }
509
// the signature of the exec join point (= signature of the function)
510
virtual const char *signature () const { return function ()->signature (); }
512
/// check whether this join point is seen by a specific tranlation unit
513
virtual bool is_known_in_tunit (File *tunit) {
514
return function ()->is_known_in_tunit (tunit);
518
class JPL_MethodCall : public JPL_Code {
521
vector<JPL_Type *> _arg_types;
522
JPL_Type *_result_type;
525
JPL_MethodCall () { _lid = -1; }
526
JPL_MethodCall (const JPL_MethodCall &jpl) : JPL_Code (jpl),
527
_target_id (jpl._target_id) {}
528
JPL_MethodCall (RepoXMLNode node, RepoXMLNode::iter &curr) :
529
JPL_Code (node, curr) {
530
_target_id = node.get_int_prop ("target");
534
virtual bool is_pseudo () const { return !parent (); }
536
JPL_Function *target_function () const {
537
return (JPL_Function*)map (_target_id);
539
void target_function (JPL_Function *f) {
540
_target_id = f->id ();
541
_sig = f->signature ();
544
// the signature of the exec join point (= signature of the function)
545
// TODO: better create the signature from the arg and result types
546
virtual const char *signature () const { return target_function ()->signature (); }
548
// for internal use only:
549
int target_id () const { return _target_id; }
551
JPL_Function *caller_function () const {
552
return (parent () && parent ()->type () == JoinPointLoc::Function) ?
553
(JPL_Function*)parent () : 0;
557
virtual int arg_count () const {
558
return (int)_arg_types.size ();
560
virtual const JPL_Type &arg_type (int i) const {
561
assert (i >= 0 && i < arg_count ());
562
return *_arg_types[i];
564
void add_arg_type (JPL_Type *type) { _arg_types.push_back (type); }
566
// manage the result type
567
void result_type (JPL_Type *type) { _result_type = type; }
568
virtual const JPL_Type &result_type () const { return *_result_type; }
570
join_point_type type () const { return MethodCall; }
571
virtual const char *type_str () const { return "call"; }
573
// the lexical scope of this code join point as needed by 'within'
574
virtual JPL_Name *lexical_scope () const { return (JPL_Name*)parent (); }
577
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
580
class JPL_Construction : public JPL_Code {
582
JPL_Construction () { _lid = -1; }
584
JPL_Construction (RepoXMLNode node, RepoXMLNode::iter &curr) :
585
JPL_Code (node, curr) {}
587
JPL_Construction (const JPL_Construction &jpl) : JPL_Code (jpl) {}
589
join_point_type type () const { return Construction; }
590
virtual const char *type_str () const { return "construction"; }
592
// the executed constructor function
593
JPL_Function *function () const { return (JPL_Function*)parent (); }
595
// the lexical scope of this code join point as needed by 'within'
596
virtual JPL_Name *lexical_scope () const { return (JPL_Name*)parent ()->parent (); }
599
virtual int arg_count () const { return function ()->arg_count (); }
600
virtual const JPL_Type &arg_type (int i) const { return function ()->arg_type (i); }
602
// manage the result type
603
const JPL_Type &result_type () const { return function ()->result_type (); }
605
// the signature of the exec join point (= signature of the function)
606
virtual const char *signature () const { return function ()->signature (); }
608
/// check whether this join point is seen by a specific tranlation unit
609
virtual bool is_known_in_tunit (File *tunit) {
610
return function ()->is_known_in_tunit (tunit);
614
class JPL_Destruction : public JPL_Code {
616
JPL_Destruction () { _lid = -1; }
618
JPL_Destruction (RepoXMLNode node, RepoXMLNode::iter &curr) :
619
JPL_Code (node, curr) {}
621
JPL_Destruction (const JPL_Destruction &jpl) : JPL_Code (jpl) {}
623
join_point_type type () const { return Destruction; }
624
virtual const char *type_str () const { return "destruction"; }
626
// the executed destructor function
627
JPL_Function *function () const { return (JPL_Function*)parent (); }
629
// the lexical scope of this code join point as needed by 'within'
630
virtual JPL_Name *lexical_scope () const { return (JPL_Name*)parent ()->parent (); }
633
virtual int arg_count () const { return function ()->arg_count (); }
634
virtual const JPL_Type &arg_type (int i) const { return function ()->arg_type (i); }
636
// manage the result type
637
const JPL_Type &result_type () const { return function ()->result_type (); }
639
// the signature of the exec join point (= signature of the function)
640
virtual const char *signature () const { return function ()->signature (); }
642
/// check whether this join point is seen by a specific tranlation unit
643
virtual bool is_known_in_tunit (File *tunit) {
644
return function ()->is_known_in_tunit (tunit);
652
JPL_Advice (CTree *pce = 0) : _pce (pce) {}
653
CTree *expr () const { return _pce; }
654
void expr (CTree *pce) { _pce = pce; }
657
class JPL_AdviceCode : public JPL_Advice, public JPL_Function {
659
enum advice_type { ADVICE_BEFORE, ADVICE_AROUND, ADVICE_AFTER };
666
JPL_AdviceCode (const string &n, const string &s) :
667
JPL_Function (n, s) {
668
const char *nm = n.c_str ();
669
if (strstr (nm, "before"))
670
_type = ADVICE_BEFORE;
671
else if (strstr (nm, "after"))
672
_type = ADVICE_AFTER;
674
_type = ADVICE_AROUND;
676
JPL_AdviceCode (const JPL_AdviceCode &jpl) : JPL_Advice (jpl), JPL_Function (jpl),
677
_pce (jpl._pce), _type (jpl._type) {}
678
JPL_AdviceCode (RepoXMLNode node, RepoXMLNode::iter &curr);
679
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
681
virtual join_point_type type () const { return AdviceCode; }
682
virtual const char *type_str () const {
684
case ADVICE_BEFORE: return "advice-before";
685
case ADVICE_AROUND: return "advice-around";
686
case ADVICE_AFTER: return "advice-after";
229
class JPL_Method : public JPL_Code
231
CFunctionInfo *_func_info;
235
JPL_Method (CFunctionInfo *f);
237
join_point_type type () { return Method; }
238
virtual const char *type_str () const { return "exec"; }
239
virtual CTree *tree () const;
240
virtual CTypeInfo *target_type () const;
241
virtual CTypeInfo *that_type ();
242
CFunctionInfo *func_info () { return _func_info; }
243
virtual CObjectInfo *assoc_obj () { return _func_info; }
244
virtual Token *insertloc_tjp_struct();
245
virtual Token *insertloc_before () { return _func_info->Tree ()->token (); }
246
virtual Token *insertloc_after () { return _func_info->Tree ()->end_token (); }
247
CFunctionInfo *tjp_type() {return _func_info;}
248
CFunctionInfo *tjp_target() {return _func_info;}
249
CFunctionInfo *tjp_that() {return _func_info;}
250
CFunctionInfo *action_dst_func() {return _func_info;}
251
CFunctionInfo *action_src_func() {return _func_info;}
252
virtual bool proceed_needs_that () const {
253
return needs_this (_func_info);
257
class JPL_MethodCall : public JPL_Code
259
CFunctionInfo *called_func;
260
CObjectInfo *caller_obj;
266
JPL_MethodCall (CFunctionInfo *called, CT_CallExpr *ce,
267
CObjectInfo *caller, int local_id, bool mi);
269
virtual bool is_pseudo () const { return !caller_obj; }
270
CFunctionInfo *caller () {
271
return caller_obj ? caller_obj->FunctionInfo () : 0;
273
CFunctionInfo *called () const { return called_func; }
274
bool in_member_init () const { return _member_init; }
276
const char *type_called() { return _sig.c_str (); }
278
// the call expression node in the syntax tree
279
CT_CallExpr *CallExprNode() const { return node;}
281
// the target object of the call or NULL
282
CT_Expression *target_expr (bool &is_ptr) const;
284
// checks if the original call uses a qualified target function name
285
bool is_qualified () const;
287
// returns true if the call needs special access rights
288
bool needs_rights () const;
290
join_point_type type () { return MethodCall; }
291
virtual const char *type_str () const { return "call"; }
292
virtual CTree *tree () const;
293
virtual CTypeInfo *that_type ();
294
virtual CTypeInfo *target_type () const;
295
virtual CObjectInfo *assoc_obj () { return caller_obj; }
296
virtual Token *insertloc_tjp_struct();
297
virtual Token *insertloc_before ();
298
virtual Token *insertloc_after ();
299
CFunctionInfo *tjp_type() { return called_func;}
300
CFunctionInfo *tjp_target() { return called_func;}
301
CFunctionInfo *tjp_that() { return caller_obj->FunctionInfo ();}
302
CFunctionInfo *action_dst_func() {return called_func;}
303
CFunctionInfo *action_src_func() {return caller_obj->FunctionInfo ();}
305
virtual bool proceed_needs_target () const {
306
return needs_this (called_func);
308
virtual bool proceed_needs_fptr () const {
309
return needs_rights ();
313
class JPL_FieldReference : public JPL_Code
315
CAttributeInfo *attr;
320
JPL_FieldReference (CAttributeInfo *a, CTree *f, int local_id);
321
join_point_type type () { return FieldReference; }
322
virtual const char *type_str () const { return "get"; }
323
virtual CTree *tree () const;
324
virtual CTypeInfo *that_type ();
325
virtual CTypeInfo *target_type () const;
328
class JPL_FieldAssignment : public JPL_Code
330
CAttributeInfo *attr;
331
CT_CallExpr *assignment;
336
JPL_FieldAssignment (CAttributeInfo *a, CT_CallExpr *as,
337
CTree *f, int local_id);
338
join_point_type type () { return FieldAssignment; }
339
virtual const char *type_str () const { return "set"; }
340
virtual CTree *tree () const;
341
virtual CTypeInfo *that_type ();
342
virtual CTypeInfo *target_type () const;
345
class JPL_Construction : public JPL_Code
347
CFunctionInfo *_func_info;
351
JPL_Construction (CFunctionInfo *f);
353
join_point_type type () { return Construction; }
354
virtual const char *type_str () const { return "construction"; }
355
virtual CTree *tree () const;
356
virtual CTypeInfo *that_type ();
357
virtual CTypeInfo *target_type () const;
358
CFunctionInfo *func_info () { return _func_info; }
359
virtual CObjectInfo *assoc_obj () { return _func_info; }
360
virtual Token *insertloc_tjp_struct();
361
virtual Token *insertloc_before () { return _func_info->Tree ()->token (); }
362
virtual Token *insertloc_after () { return _func_info->Tree ()->end_token (); }
363
CFunctionInfo *tjp_type() {return _func_info;}
364
CFunctionInfo *tjp_target() {return _func_info;}
365
CFunctionInfo *tjp_that() {return _func_info;}
366
CFunctionInfo *action_dst_func() {return _func_info;}
367
CFunctionInfo *action_src_func() {return _func_info;}
368
virtual bool proceed_needs_that () const { return true; }
371
class JPL_Destruction : public JPL_Code
373
CFunctionInfo *_func_info;
377
JPL_Destruction (CFunctionInfo *f);
379
join_point_type type () { return Destruction; }
380
virtual const char *type_str () const { return "destruction"; }
381
virtual CTree *tree () const;
382
virtual CTypeInfo *that_type ();
383
virtual CTypeInfo *target_type () const;
384
CFunctionInfo *func_info () { return _func_info; }
385
virtual CObjectInfo *assoc_obj () { return _func_info; }
386
virtual Token *insertloc_tjp_struct();
387
virtual Token *insertloc_before () { return _func_info->Tree ()->token (); }
388
virtual Token *insertloc_after () { return _func_info->Tree ()->end_token (); }
389
CFunctionInfo *tjp_type() {return _func_info;}
390
CFunctionInfo *tjp_target() {return _func_info;}
391
CFunctionInfo *tjp_that() {return _func_info;}
392
CFunctionInfo *action_dst_func() {return _func_info;}
393
CFunctionInfo *action_src_func() {return _func_info;}
394
virtual bool proceed_needs_that () const { return true; }
688
return "error"; // just to suppress warnings
691
advice_type type () { return _type; }
694
class JPL_Introduction : public JPL_Advice, public JoinPointLoc {
697
JPL_Introduction () : _slice_id (-1) {
700
JPL_Introduction (RepoXMLNode node, RepoXMLNode::iter &curr);
701
JPL_Introduction (const JPL_Introduction &jpl) : JPL_Advice (jpl), _slice_id (0) {}
702
virtual RepoXMLNode make_xml (RepoXMLNode parent) const;
704
void parent (JPL_Aspect *ai) {
705
JoinPointLoc::parent (ai);
706
ai->intro_infos ().push_back (this);
708
using JoinPointLoc::parent;
710
int slice_id () const { return _slice_id; }
712
virtual join_point_type type () const { return Introduction; }
713
const char *type_str () const { return "intro"; }
714
void introduced (JPL_ClassSlice *s) { _slice_id = s->id (); }
715
JPL_ClassSlice *introduced () const { return (JPL_ClassSlice*)map (_slice_id); }
718
class JPL_Order : public JPL_Advice, public JoinPointLoc {
725
void parent (JPL_Aspect *ai) {
726
JoinPointLoc::parent (ai);
727
ai->order_infos ().push_back (this);
729
using JoinPointLoc::parent;
731
virtual join_point_type type () const { return Order; }
732
virtual const char *type_str () const { return "order"; }
734
void add_pce (CTree *pce) { _pces.push_back (pce); }
735
const list<CTree*> &pces () const { return _pces; }
397
738
#endif // __join_point_loc_h__