1
// This file is part of the AspectC++ compiler 'ac++'.
2
// Copyright (C) 1999-2003 The 'ac++' developers (see aspectc.org)
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.
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.
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,
19
#ifndef __ModelBuilder_h__
20
#define __ModelBuilder_h__
22
#include "JoinPointModel.h"
23
#include "TransformInfo.h"
26
class CTranslationUnit;
31
class ACIntroductionInfo;
41
CAttributeInfo *_info;
44
AccessInfo (CAttributeInfo *info, CTree *tree) :
45
_info (info), _tree (tree) {}
49
class ModelBuilder : public JoinPointModel {
58
// map needed to check if a file is already known
59
typedef map<Unit*, File*> FileMap;
60
typedef FileMap::value_type FileMapPair;
63
// TODO: temporary solution
64
list<AccessInfo> _access_infos;
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);
72
// determine a model element filename for a unit
73
string model_filename (FileUnit *unit);
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;
85
// create a type in the join point model from a Puma node
86
TU_Type *register_type (CTypeInfo *ti);
88
// create a function in the join point model from a Puma node
89
TU_Function *register_function (CFunctionInfo *fi, JPL_Name *parent = 0);
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);
94
// create a class in the join point model from a Puma node
95
TU_Class *register_class (CClassInfo *ci, JPL_Name *parent = 0);
97
// create an aspect in the join point model from a Puma node
98
TU_Aspect *register_aspect (ACAspectInfo *ai, JPL_Name *parent = 0);
100
// create a Namespace in the join point model from a Puma node
101
TU_Namespace *register_namespace (CNamespaceInfo *ni, JPL_Name *parent = 0);
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);
107
// create a new execution join point
108
TU_Method *register_execution (JPL_Function *ef);
110
// create a new construction join point
111
TU_Construction *register_construction (JPL_Function *cf);
113
// create a new construction join point
114
TU_Destruction *register_destruction (JPL_Function *df);
116
// TODO: temporary solution for dac++
117
void register_attr_access (CAttributeInfo *attr, CTree *node);
119
// register the scope of a given element
120
JPL_Name *register_scope (CObjectInfo *obj);
122
// return the name of the scope of an object
123
static string scope_name (CObjectInfo *oi);
125
// return the scope of an object
126
static CScopeInfo *scope_obj (CObjectInfo *oi);
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);
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);
136
// determine the file unit, which contains a specific syntax (sub-)tree
137
FileUnit *source_unit (CTree *tree);
139
// TODO: temporary solution
140
const list<AccessInfo> &access_infos () const { return _access_infos; }