File: PointCutExpr.h

package info (click to toggle)
aspectc%2B%2B 1%3A2.2%2Bgit20181008-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 18,704 kB
  • sloc: cpp: 110,629; ansic: 7,644; sh: 2,192; makefile: 1,317; pascal: 634; python: 402; xml: 349
file content (597 lines) | stat: -rw-r--r-- 23,255 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
// This file is part of the AspectC++ compiler 'ac++'.
// Copyright (C) 1999-2003  The 'ac++' developers (see aspectc.org)
//                                                                
// This program is free software;  you can redistribute it and/or 
// modify it under the terms of the GNU General Public License as 
// published by the Free Software Foundation; either version 2 of 
// the License, or (at your option) any later version.            
//                                                                
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
// GNU General Public License for more details.                   
//                                                                
// You should have received a copy of the GNU General Public      
// License along with this program; if not, write to the Free     
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
// MA  02111-1307  USA                                            

#ifndef __PointCutExpr_h__
#define __PointCutExpr_h__

#ifdef FRONTEND_PUMA
namespace Puma {
  class CTypeInfo;
}
#else // FRONTEND_CLANG
#include "clang/AST/Type.h"
#endif

#include "Condition.h"
#include "PointCut.h"
#include "ACErrorStream.h"

#include "ACModel/MatchExpr.h"
#include "ACModel/Elements.h"
#include "ACModel/Utils.h"

#include <list>
#include <string>
#include "Puma/Array.h" // TODO: replace by STL container

class Binding;
class PointCutContext;

// Pointcut expression types are evaluated in a context-independant manner.
// For every pointcut expression a type can always be determined.
enum PCE_Type { 
  PCE_NAME, // NAME represents a name pointcut
  PCE_CODE // CODE represents a code pointcut
};

class PointCutExpr : public PointcutExpressionNode {

protected:

  enum { PRE_EVAL_OFF, PRE_EVAL_ON, PRE_EVAL_DONE } _pre_evaluate;
  ACM_Any *_jpl;
  JoinPointType _possible_types;

  // do a semantic analysis of the child nodes
  void sem_args (ACErrorStream &err, PointCutContext &context, int warn_compat);

  // check if the argument pointcut types are as expected
  void check_arg_types (ACErrorStream &err, const char *func, PCE_Type expected,
      PointCutContext &context);

  // check if all argument types are equal
  void check_arg_types_equal (ACErrorStream &err, const char *func,
      PointCutContext &context);

  // get the real argument binding of a context variable
  const ACM_Arg *get_binding (const char *name, ACErrorStream &err,
      PointCutContext &context);
public:

  PointCutExpr () : _pre_evaluate (PRE_EVAL_OFF), _jpl (0),
    _possible_types((JoinPointType)0) {}
  virtual ~PointCutExpr () {}

  // Return the type of pointcut described by this expression. This function
  // does not check any argument types etc. -> semantics!
  virtual PCE_Type type () const = 0;

  // return a bit mask of join point types that could match; others can't!
  int possible_types () const { return (int)_possible_types; }

  // run a semantic analysis (e.g. check types)
  virtual void semantics (ACErrorStream &err, PointCutContext &context,
      int warn_compat) = 0;

  // evaluate an expression, i.e. check if the expression evaluates as 'true'
  // for a particular join point
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond) = 0;

  // if the expression supports pre-evaluation, do it in this function
  virtual void pre_evaluate (PointCutContext &context) {}

  bool match (ACM_Any &jpl, PointCutContext &context,
              Binding &binding, Condition &cond) {
    if (_pre_evaluate == PRE_EVAL_ON)
      pre_evaluate(context);
    if (_pre_evaluate == PRE_EVAL_OFF)
      return evaluate (jpl, context, binding, cond);
    return (&jpl == _jpl);
  }
                         
  // mangle a string that represents a type check (for that/target arguments)                         
  virtual void mangle_type_check (ostream &) = 0;

  // helper functions to get the right result type
  virtual PointCutExpr* duplicate () = 0;
  virtual PointCutExpr *arg (int i) const = 0;
};

class PCE_SingleArg : public PointCutExpr {
  PointCutExpr *_arg;
public:
  PCE_SingleArg (PointCutExpr *arg) : _arg (arg) {}

  virtual int args () const { return 1; }
  virtual PointCutExpr *arg (int i) const { return (i == 0) ? _arg : 0; }
  void replace_arg (PointCutExpr *expr) { if (_arg) _arg->ref(-1); _arg = expr; }

  bool check_derived_class (ACM_Class &cls,
    PointCutContext &context, Binding &binding, Condition &cond);
  bool check_derived_func (ACM_Class &cls, ACM_Function &func, 
    PointCutContext &context, Binding &binding, Condition &cond);
  bool check_derived_var (ACM_Class &cls, ACM_Variable &var,
    PointCutContext &context, Binding &binding, Condition &cond);
  bool check_base_class (ACM_Class &cls, PointCutContext &context,
    Binding &binding, Condition &cond);
  bool check_base_func (ACM_Class &cls, ACM_Function &func, 
    PointCutContext &context, Binding &binding, Condition &cond);
  bool check_base_var (ACM_Class &cls, ACM_Variable &var,
    PointCutContext &context, Binding &binding, Condition &cond);
  bool check_scopes (ACM_Name *scope,
    PointCutContext &context, Binding &binding, Condition &cond);
  
  virtual void mangle_type_check (ostream &out) {
    out << 1;
    _arg->mangle_type_check (out);
  }
};

class PCE_DoubleArg : public PointCutExpr {
  PointCutExpr *_args[2];
public:
  PCE_DoubleArg (PointCutExpr *arg0, PointCutExpr *arg1) {
    _args[0] = arg0; _args[1] = arg1; 
  }
  virtual int args () const { return 2; }
  virtual PointCutExpr *arg (int i) const { 
    return (i >= 0 && i < 2) ? _args[i] : 0; 
  }
  virtual void mangle_type_check (ostream &out) {
    out << 2;
    _args[0]->mangle_type_check (out);
    _args[1]->mangle_type_check (out);
  }
};

class PCE_VarArgs : public PointCutExpr {
  Puma::Array<PointCutExpr*> _args; // TODO: replace by STL container
public:
  virtual ~PCE_VarArgs () {}
  void add_arg (PointCutExpr *arg) { _args.append (arg); }
  virtual int args () const { return _args.length (); }
  virtual PointCutExpr *arg (int i) const { return _args.lookup (i); }
  virtual void mangle_type_check (ostream &out) {
    out << args ();
    for (int i = 0; i < args (); i++)
      arg (i)->mangle_type_check (out);
  }
};

class PCE_Classes : public PCE_SingleArg {
public:
  PCE_Classes (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "classes_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Classes* duplicate () { return new PCE_Classes(arg(0)->duplicate ()); }
};

class PCE_Base : public PCE_SingleArg {
public:
  PCE_Base (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "base_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Base* duplicate () { return new PCE_Base(arg(0)->duplicate ()); }
};

class PCE_Derived : public PCE_SingleArg {
public:
  PCE_Derived (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "derived_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Derived* duplicate () { return new PCE_Derived(arg(0)->duplicate ()); }
};

class PCE_Within : public PCE_SingleArg {
public:
  PCE_Within (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "within_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Within* duplicate () { return new PCE_Within(arg(0)->duplicate ()); }
};

class PCE_Member : public PCE_SingleArg {
public:
  PCE_Member( PointCutExpr *arg ) : PCE_SingleArg( arg ) {}
  virtual PCE_Type type() const;
  virtual void semantics( ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate( ACM_Any &jpl, PointCutContext &context, Binding &binding, Condition &cond );
  virtual void mangle_type_check( ostream &out ) {
    out << "member_";
    PCE_SingleArg::mangle_type_check( out );
  }
  virtual PCE_Member* duplicate () { return new PCE_Member( arg(0)->duplicate () ); }
};

class PCE_Execution : public PCE_SingleArg {
public:
  PCE_Execution (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "execution_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Execution* duplicate () { return new PCE_Execution(arg(0)->duplicate ()); }
};

class PCE_Call : public PCE_SingleArg {
public:
  PCE_Call (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "call_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Call* duplicate () { return new PCE_Call(arg(0)->duplicate ()); }
};

class PCE_Builtin : public PCE_SingleArg {
public:
  PCE_Builtin (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "builtin";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Builtin* duplicate () { return new PCE_Builtin(arg(0)->duplicate ()); }
};

class PCE_Get : public PCE_SingleArg {
public:
  PCE_Get( PointCutExpr *arg ) : PCE_SingleArg( arg ) {}
  virtual PCE_Type type () const;
  virtual void semantics( ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate( ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond );
  virtual void mangle_type_check( ostream &out ) {
    out << "get_";
    PCE_SingleArg::mangle_type_check( out );
  }
  virtual PCE_Get* duplicate() { return new PCE_Get( arg(0)->duplicate() ); }
};

class PCE_Set : public PCE_SingleArg {
public:
  PCE_Set( PointCutExpr *arg ) : PCE_SingleArg( arg ) {}
  virtual PCE_Type type () const;
  virtual void semantics( ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate( ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond );
  virtual void mangle_type_check( ostream &out ) {
    out << "set_";
    PCE_SingleArg::mangle_type_check( out );
  }
  virtual PCE_Set* duplicate() { return new PCE_Set( arg(0)->duplicate() ); }
};

class PCE_Ref : public PCE_SingleArg {
public:
  PCE_Ref( PointCutExpr *arg ) : PCE_SingleArg( arg ) {}
  virtual PCE_Type type () const;
  virtual void semantics( ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate( ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond );
  virtual void mangle_type_check( ostream &out ) {
    out << "ref_";
    PCE_SingleArg::mangle_type_check( out );
  }
  virtual PCE_Ref* duplicate() { return new PCE_Ref( arg(0)->duplicate() ); }
};

class PCE_Alias : public PCE_SingleArg {
public:
  PCE_Alias( PointCutExpr *arg ) : PCE_SingleArg( arg ) {}
  virtual PCE_Type type () const;
  virtual void semantics( ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate( ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond );
  virtual void mangle_type_check( ostream &out ) {
    out << "alias_";
    PCE_SingleArg::mangle_type_check( out );
  }
  virtual PCE_Alias* duplicate() { return new PCE_Alias( arg(0)->duplicate() ); }
};

class PCE_Construction : public PCE_SingleArg {
public:
  PCE_Construction (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "construction_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Construction* duplicate () { return new PCE_Construction(arg(0)->duplicate ()); }
};

class PCE_Destruction : public PCE_SingleArg {
public:
  PCE_Destruction (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "destruction_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Destruction* duplicate () { return new PCE_Destruction(arg(0)->duplicate ()); }
};

class PCE_That : public PCE_SingleArg {
public:
  PCE_That (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "that_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_That* duplicate () { return new PCE_That(arg(0)->duplicate ()); }
};

class PCE_Target : public PCE_SingleArg {
public:
  PCE_Target (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "target_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Target* duplicate () { return new PCE_Target(arg(0)->duplicate ()); }
};

class PCE_CFlow : public PCE_SingleArg {
  int _index;
  PointCut _arg_pointcut;
public:
  PCE_CFlow (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual ~PCE_CFlow () {}
  virtual PCE_Type type () const;
  PointCut &arg_pointcut () { return _arg_pointcut; }
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "cflow_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_CFlow* duplicate () { return new PCE_CFlow(arg(0)->duplicate ()); }
};

class PCE_Args : public PCE_VarArgs {
  bool _both_sc_args_bound_warning_created;
  bool _sc_arg_bound_warning_created;
public:
  PCE_Args () : _both_sc_args_bound_warning_created(false),
                _sc_arg_bound_warning_created(false) {}
  PCE_Args (bool both_sc_args_bound_warning_created,
            bool sc_arg_bound_warning_created) :
        _both_sc_args_bound_warning_created(both_sc_args_bound_warning_created),
        _sc_arg_bound_warning_created(sc_arg_bound_warning_created){}
  virtual ~PCE_Args () {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "args_";
    PCE_VarArgs::mangle_type_check (out);
  }
  virtual PCE_Args* duplicate () {
    PCE_Args *result = new PCE_Args(_both_sc_args_bound_warning_created,
        _sc_arg_bound_warning_created);
    for (int i = 0; i < args(); i++)
      result->add_arg(arg(i)->duplicate ());
    return result;
  }
};

class PCE_Result : public PCE_SingleArg {
public:
  PCE_Result (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "result_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Result* duplicate () { return new PCE_Result(arg(0)->duplicate ()); }
};

class PCE_Or : public PCE_DoubleArg {
public:
  PCE_Or (PointCutExpr *arg0, PointCutExpr *arg1) : 
    PCE_DoubleArg (arg0, arg1) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "or_";
    PCE_DoubleArg::mangle_type_check (out);
  }
  virtual PCE_Or* duplicate () { return new PCE_Or(arg(0)->duplicate (), arg(1)->duplicate()); }
};

class PCE_And : public PCE_DoubleArg {
public:
  PCE_And (PointCutExpr *arg0, PointCutExpr *arg1) : 
    PCE_DoubleArg (arg0, arg1) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "and_";
    PCE_DoubleArg::mangle_type_check (out);
  }
  virtual PCE_And* duplicate () { return new PCE_And(arg(0)->duplicate (), arg(1)->duplicate()); }
};

class PCE_Not : public PCE_SingleArg {
public:
  PCE_Not (PointCutExpr *arg) : PCE_SingleArg (arg) {}
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "not_";
    PCE_SingleArg::mangle_type_check (out);
  }
  virtual PCE_Not* duplicate () { return new PCE_Not(arg(0)->duplicate ()); }
};

class PCE_Named : public PointCutExpr {
  ACM_Pointcut *_pct_func;
  PointcutExpression _expr;
  std::list<std::string> _params;
public:
  PCE_Named (ACM_Pointcut *pct_func) : _pct_func (pct_func) {}
  virtual PCE_Type type () const;
  std::list<std::string> &params () { return _params; }
  PointcutExpression &expr () { return _expr; }
  virtual int args () const { return 0; }
  virtual PointCutExpr *arg (int) const { return 0; }
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "named_";
    ((PointCutExpr*)_expr.get())->mangle_type_check (out);
  }
  virtual PCE_Named* duplicate () {
    PCE_Named *result = new PCE_Named(_pct_func);
    result->_expr = _expr;
    result->_params = _params;
    return result;
  }
};

class PCE_CXX11Attr : public PointCutExpr {
  ACM_Attribute *_pct_attr;
  std::list<std::string> _params;
public:
  PCE_CXX11Attr ( ACM_Attribute *pct_attr ) : _pct_attr(pct_attr) {}

  virtual PCE_Type type () const {return PCE_NAME;}
  std::list<std::string> &params () { return _params; }
  virtual int args() const {return 0;} //Is this right?
  virtual PointCutExpr *arg(int) const {return 0;} //Is this right?
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out) {
    out << "named_";
    arg(0)->mangle_type_check (out);
  }
  virtual PCE_CXX11Attr* duplicate () {
    PCE_CXX11Attr *result = new PCE_CXX11Attr(_pct_attr);
    result->_params = _params;
    return result;
  }
};

class PCE_ContextVar : public PointCutExpr {
  string _name;
  const ACM_Arg *_bound_arg;
#ifdef FRONTEND_PUMA  // TODO: get rid of frontend types here
  const Puma::CTypeInfo *_check_type;
#else // FRONTEND_CLANG
  clang::QualType _check_type;
#endif
  enum { CV_THAT, CV_TARGET, CV_ARG, CV_RESULT } _bound_to;
  int _arg;
public:
  PCE_ContextVar (const string &name) : _name (name) {}
  virtual int args () const { return 0; }
  virtual PointCutExpr *arg (int) const { return 0; }
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out);
  virtual PCE_ContextVar* duplicate () { return new PCE_ContextVar(_name); }
};

class PCE_Match : public PointCutExpr {
  MatchExpr _match_expr;
  string _str;
public:
  PCE_Match (const string &str) : _str (str) {}
  virtual ~PCE_Match () {}
  virtual int args () const { return 0; }
  virtual PointCutExpr *arg (int) const { return 0; }
  virtual PCE_Type type () const;
  virtual void semantics (ACErrorStream &err, PointCutContext &context, int warn_compat);
  bool parse ();

  // if the expression supports pre-evaluation, do it in this function
  virtual void pre_evaluate (PointCutContext &context);
  void pre_evaluate (const MatchName &name, PointCutContext &context);
  virtual bool evaluate (ACM_Any &jpl, PointCutContext &context,
                         Binding &binding, Condition &cond);
  virtual void mangle_type_check (ostream &out);
  virtual PCE_Match* duplicate () { ref(1); return this; }
};

#endif // __PointCutExpr_h__