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

« back to all changes in this revision

Viewing changes to AspectC++/ModelBuilder.h

  • 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:
 
1
// This file is part of the AspectC++ compiler 'ac++'.
 
2
// Copyright (C) 1999-2003  The 'ac++' developers (see aspectc.org)
 
3
//                                                                
 
4
// This program is free software;  you can redistribute it and/or 
 
5
// modify it under the terms of the GNU General Public License as 
 
6
// published by the Free Software Foundation; either version 2 of 
 
7
// the License, or (at your option) any later version.            
 
8
//                                                                
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
 
12
// GNU General Public License for more details.                   
 
13
//                                                                
 
14
// You should have received a copy of the GNU General Public      
 
15
// License along with this program; if not, write to the Free     
 
16
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 
17
// MA  02111-1307  USA                                            
 
18
 
 
19
#ifndef __ModelBuilder_h__
 
20
#define __ModelBuilder_h__
 
21
 
 
22
#include "JoinPointModel.h"
 
23
#include "TransformInfo.h"
 
24
 
 
25
namespace Puma {
 
26
  class CTranslationUnit;
 
27
  class CClassDatabase;
 
28
  class CStructure;
 
29
  class CScopeInfo;
 
30
  class ACAspectInfo;
 
31
  class ACIntroductionInfo;
 
32
  class ACSliceInfo;
 
33
  class ErrorStream;
 
34
  class VerboseMgr;
 
35
}
 
36
using namespace Puma;
 
37
 
 
38
class ACConfig;
 
39
 
 
40
struct AccessInfo {
 
41
  CAttributeInfo *_info;
 
42
  CTree *_tree;
 
43
  AccessInfo () {}
 
44
  AccessInfo (CAttributeInfo *info, CTree *tree) :
 
45
    _info (info), _tree (tree) {}
 
46
  
 
47
};
 
48
 
 
49
class ModelBuilder : public JoinPointModel {
 
50
 
 
51
  VerboseMgr &_vm;
 
52
  ErrorStream &_err;
 
53
  ACConfig &_conf;
 
54
  File *_tunit_file;
 
55
  int _phase;
 
56
  CClassDatabase *_db;
 
57
 
 
58
  // map needed to check if a file is already known
 
59
  typedef map<Unit*, File*> FileMap;
 
60
  typedef FileMap::value_type FileMapPair;
 
61
  FileMap _file_map;
 
62
 
 
63
  // TODO: temporary solution
 
64
  list<AccessInfo> _access_infos;
 
65
  
 
66
  void build (CTranslationUnit& tunit);
 
67
  void build (CStructure &structure, JPL_Name *jpl = 0);
 
68
  bool inside_template (CScopeInfo *scope) const;
 
69
  void advice_infos (JPL_Aspect *jpl_aspect, ACAspectInfo *acai);
 
70
  void check (JPL_Aspect *jpl_aspect, ACIntroductionInfo *acii, JPL_Introduction *intro);
 
71
  
 
72
  // determine a model element filename for a unit
 
73
  string model_filename (FileUnit *unit);
 
74
  
 
75
public:
 
76
  ModelBuilder (VerboseMgr &vm, ErrorStream &err, ACConfig &conf) :
 
77
    _vm (vm), _err (err), _conf (conf), _phase (0) {}
 
78
  void setup_phase1 (CTranslationUnit& tunit);
 
79
  void setup_phase2 (CTranslationUnit& tunit, list<CTree*> &ah_trees);
 
80
  bool is_valid_model_class (CClassInfo *ci) const;
 
81
  bool is_intro_target (CClassInfo *ci) const;
 
82
  bool is_valid_model_function (CFunctionInfo *fi) const;
 
83
  bool is_valid_model_namespace (CNamespaceInfo *ni) const;
 
84
 
 
85
  // create a type in the join point model from a Puma node
 
86
  TU_Type *register_type (CTypeInfo *ti);
 
87
 
 
88
  // create a function in the join point model from a Puma node
 
89
  TU_Function *register_function (CFunctionInfo *fi, JPL_Name *parent = 0);
 
90
  
 
91
  // create a class slice in the join point model from a Puma node
 
92
  TU_ClassSlice *register_class_slice (ACSliceInfo *acsi, JPL_Name *parent = 0);
 
93
 
 
94
  // create a class in the join point model from a Puma node
 
95
  TU_Class *register_class (CClassInfo *ci, JPL_Name *parent = 0);
 
96
 
 
97
  // create an aspect in the join point model from a Puma node
 
98
  TU_Aspect *register_aspect (ACAspectInfo *ai, JPL_Name *parent = 0);
 
99
 
 
100
  // create a Namespace in the join point model from a Puma node
 
101
  TU_Namespace *register_namespace (CNamespaceInfo *ni, JPL_Name *parent = 0);
 
102
 
 
103
  // create a new call join point in the join point model
 
104
  TU_MethodCall *register_call (CFunctionInfo *called, CT_Call *call_node,
 
105
    CObjectInfo *caller, int local_id);
 
106
 
 
107
  // create a new execution join point
 
108
  TU_Method *register_execution (JPL_Function *ef);
 
109
  
 
110
  // create a new construction join point
 
111
  TU_Construction *register_construction (JPL_Function *cf);
 
112
  
 
113
  // create a new construction join point
 
114
  TU_Destruction *register_destruction (JPL_Function *df);
 
115
  
 
116
  // TODO: temporary solution for dac++
 
117
  void register_attr_access (CAttributeInfo *attr, CTree *node);
 
118
 
 
119
  // register the scope of a given element
 
120
  JPL_Name *register_scope (CObjectInfo *obj);
 
121
 
 
122
  // return the name of the scope of an object
 
123
  static string scope_name (CObjectInfo *oi);
 
124
  
 
125
  // return the scope of an object
 
126
  static CScopeInfo *scope_obj (CObjectInfo *oi);
 
127
 
 
128
  // add the source location to a model element by using a given CObjectInfo
 
129
  void add_source_loc (JoinPointLoc *name, CObjectInfo *obj, SourceLocKind kind = SLK_NONE) {
 
130
    add_source_loc (name, obj->Tree (), kind);
 
131
  }
 
132
 
 
133
  // add the source location to a model element by using the syntax tree node
 
134
  void add_source_loc (JoinPointLoc *name, CTree *tree, SourceLocKind kind = SLK_NONE);
 
135
  
 
136
  // determine the file unit, which contains a specific syntax (sub-)tree
 
137
  FileUnit *source_unit (CTree *tree);
 
138
  
 
139
  // TODO: temporary solution
 
140
  const list<AccessInfo> &access_infos () const { return _access_infos; }
 
141
};
 
142
 
 
143
#endif