Debian Codegraph @

AspectC++/doc/CompilerManual/aspectc++ code transformation/acc-examples/ah_get.acc

raw
1 #line 1 "ah_get/main.cc"
2 #ifndef __ac_FIRST__home_Tom_aspectcX43X43__
3 #define __ac_FIRST__home_Tom_aspectcX43X43__
4 #define __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_get_main_cc__
5 #ifndef __ac_have_predefined_includes__
6 #define __ac_have_predefined_includes__
7 #endif // __ac_have_predefined_includes__
8
9 #ifndef __ac_h_
10 #define __ac_h_
11 #ifdef __cplusplus
12 namespace AC {
13 typedef const char* Type;
14 enum JPType { GET = 65536, SET = 131072, REF = 1048576, BUILTIN = 524288, CALL = 262144, EXECUTION = 16777216, CONSTRUCTION = 33554432, DESTRUCTION = 67108864 };
15 enum Protection { PROT_NONE, PROT_PRIVATE, PROT_PROTECTED, PROT_PUBLIC };
16 enum Specifiers { SPEC_NONE = 0x0 , SPEC_STATIC = 0x1, SPEC_MUTABLE = 0x2, SPEC_VIRTUAL = 0x4 };
17 struct Action {
18 void **_args; void *_result; void *_entity; void *_array; void **_indices; void *_target; void *_that; void *_fptr;
19 void (*_wrapper)(Action &);
20 inline void trigger () { _wrapper (*this); }
21 };
22 template <typename T> struct ResultBuffer {
23 char _data[sizeof (T)];
24 void operator = (const T& t) { *this = (const ResultBuffer &)t; }
25 };
26 template <typename T, typename N> struct TL {
27 typedef T type; typedef N next; enum { ARGS = next::ARGS + 1 };
28 };
29 struct TLE { enum { ARGS = 0 }; };
30 template <typename T> struct Referred { typedef T type; };
31 template <typename T> struct Referred<T &> { typedef T type; };
32 template <typename TL, int I> struct Arg {
33 typedef typename Arg<typename TL::next, I - 1>::Type Type;
34 typedef typename Referred<Type>::type ReferredType;
35 };
36 template <typename TL> struct Arg<TL, 0> {
37 typedef typename TL::type Type;
38 typedef typename Referred<Type>::type ReferredType;
39 };
40 template <typename T, bool Qual> struct ConstQualify {};
41 template <typename T> struct ConstQualify<T, false> { typedef T type; };
42 template <typename T> struct ConstQualify<T, true> { typedef const T type; };
43 template <typename T> struct ConstQualify<const T, true> { typedef const T type; };
44 template <typename TL, unsigned int FC, int I> struct ArgCQ {
45 typedef typename ConstQualify<typename Arg<TL, I>::Type, ( FC >> I ) & 1>::type Type;
46 typedef typename Referred<Type>::type ReferredType;
47 };
48 template <typename T> int ttest(...);
49 template <typename T> char ttest(typename T::__TI const volatile *);
50 template<typename T> struct HasTypeInfo {
51 enum { RET=((sizeof(ttest<T>(0))==1)?1:0) };
52 };
53 template<typename T, int HAVE = HasTypeInfo<T>::RET> struct TypeInfo {
54 enum { AVAILABLE = 0, BASECLASSES = 0, MEMBERS = 0, FUNCTIONS = 0,
55 CONSTRUCTORS = 0, DESTRUCTORS = 0 };
56 typedef T That;
57 };
58 template<typename T> struct TypeInfo<T, 1> : T::__TI {
59 enum { AVAILABLE = 1 };
60 };
61 template<typename T> struct RT {};
62 template<typename T> RT<T> rt_deduce (const T&) { return RT<T>(); }
63 template<typename T> RT<T> rt_deduce (const volatile T&) { return RT<T>(); }
64 struct Cnv { template<typename T> operator RT<T>() const { return RT<T>(); }};
65 #define __AC_TYPEOF(expr) (1?AC::Cnv():AC::rt_deduce(expr))
66 template <class Aspect, int Index>
67 struct CFlow {
68 static int &instance () {
69 static int counter = 0;
70 return counter;
71 }
72 CFlow () { instance ()++; }
73 ~CFlow () { instance ()--; }
74 static bool active () { return instance () > 0; }
75 };
76 template <typename T, typename E, typename O> inline E T::* mptr_castT( E O::*mptr ) { return static_cast< E T::* >( mptr ); }
77 template <typename A> struct SpliceT {};
78 template <typename B, unsigned int D> struct SpliceT< B[D] > {
79 typedef B Base;
80 enum { Dim = D };
81 };
82 template <unsigned int TSize, typename TIdx, typename N> struct DIL : N {
83 typedef N Next;
84 enum { Count = Next::Count + 1 };
85 enum { Size = TSize };
86 typedef TIdx Idx;
87 Idx idx;
88 template <typename B> struct Entity { typedef typename SpliceT< typename Next::template Entity<B>::Type >::Base Type; };
89 template <typename E> struct Array { typedef typename Next::template Array<E>::Type Type[Size]; };
90 template <typename E> inline E& apply( typename Array<E>::Type &base ) { return Next::template apply<E>( base[idx] ); }
91 template <typename A> struct Append { typedef DIL<Size, Idx, typename Next::template Append<A>::NewList > NewList; };
92 template <typename ONext> inline void copyTo( DIL<Size,Idx,ONext> *target ) {
93 target->idx = idx;
94 Next::copyTo( static_cast<ONext *>( target ) );
95 };
96 };
97 struct DILE {
98 enum { Count = 0 };
99 template <typename B> struct Entity { typedef B Type; };
100 template <typename E> struct Array { typedef E Type; };
101 template <typename E> inline E& apply( typename Array<E>::Type &base ) { return base; }
102 template <typename A> struct Append { typedef A NewList; };
103 template <typename O> inline void copyTo( O * ) {};
104 };
105 template <typename L, unsigned int D> struct DIL_Op {
106 enum { Size = DIL_Op<typename L::Next, D - 1>::Size };
107 typedef typename DIL_Op<typename L::Next, D - 1>::Idx Idx;
108 inline static Idx &idx( L *di ) { return DIL_Op<typename L::Next, D - 1>::idx( di ); }
109 };
110 template <typename L> struct DIL_Op<L,0> {
111 enum { Size = L::Size };
112 typedef typename L::Idx Idx;
113 inline static Idx &idx( L *di ) { return di->idx; }
114 };
115 template <typename TEntity> struct BI_Entity {
116 typedef TEntity Entity;
117 Entity &_ent;
118 inline BI_Entity( Entity &ent ) : _ent( ent ) {}
119 inline Entity &entity() { return _ent; }
120 };
121 template <typename TTarget, typename TEntity> struct BI_Member {
122 typedef TEntity Entity;
123 typedef TTarget Target;
124 typedef Entity Target::*Member;
125 Target &_target;
126 Member _member;
127 inline BI_Member( Target &target, Member mem ) : _target( target ), _member( mem ) {}
128 inline Entity &entity() { return _target.*_member; }
129 };
130 template <typename TTarget, typename TEntity> struct BI_Static {
131 typedef TEntity Entity;
132 typedef TTarget Target;
133 Entity &_ent;
134 Target &_target;
135 inline BI_Static( Target &target, Entity &ent ) : _ent( ent ), _target( target ) {}
136 inline Entity &entity() { return _ent; }
137 };
138 template <typename TBI, typename TDI> struct PackedEntity {
139 typedef PackedEntity<TBI, TDI> SELF;
140 typedef TBI BI;
141 typedef TDI DI;
142 BI _base;
143 DI _indices;
144 inline PackedEntity( BI base ) : _base( base ) {}
145 typedef typename BI::Entity Base;
146 typedef typename DI::template Entity<Base>::Type Entity;
147 inline Base &base() { return _base.entity(); };
148 inline Entity &entity() { return _indices.template apply<Entity>( base() ); }
149 enum { DIMS = DI::Count };
150 template <unsigned int D> struct Dim : DIL_Op<DI,D> {};
151 template <unsigned int D> inline typename Dim<D>::Idx &idx() { return Dim<D>::idx( &_indices ); }
152 template<typename NextIdx> struct Extend {
153 typedef typename SpliceT<Entity>::Base NewEnt;
154 enum { NextDim = SpliceT<Entity>::Dim };
155 typedef typename DI::template Append< DIL< NextDim, NextIdx, DILE > >::NewList NewDI;
156 typedef PackedEntity< BI, NewDI > NewPacked;
157 };
158 template<typename TIdxN> inline typename Extend<TIdxN>::NewPacked operator []( TIdxN idxN ) {
159 typedef typename Extend<TIdxN>::NewPacked __PE;
160 __PE res( _base );
161 _indices.copyTo( &res._indices );
162 __PE::template Dim<__PE::DIMS - 1>::idx( &res._indices ) = idxN;
163 return res;
164 }
165 inline SELF operator =( Entity arg ) { entity() = arg; return *this; }
166 template<typename ARG> inline SELF operator +=( ARG arg ) { entity() += arg; return *this; }
167 template<typename ARG> inline SELF operator -=( ARG arg ) { entity() -= arg; return *this; }
168 template<typename ARG> inline SELF operator *=( ARG arg ) { entity() *= arg; return *this; }
169 template<typename ARG> inline SELF operator /=( ARG arg ) { entity() /= arg; return *this; }
170 template<typename ARG> inline SELF operator %=( ARG arg ) { entity() %= arg; return *this; }
171 template<typename ARG> inline SELF operator |=( ARG arg ) { entity() |= arg; return *this; }
172 template<typename ARG> inline SELF operator ^=( ARG arg ) { entity() ^= arg; return *this; }
173 template<typename ARG> inline SELF operator &=( ARG arg ) { entity() &= arg; return *this; }
174 template<typename ARG> inline SELF operator <<=( ARG arg ) { entity() <<= arg; return *this; }
175 template<typename ARG> inline SELF operator >>=( ARG arg ) { entity() >>= arg; return *this; }
176 inline SELF operator ++() { ++entity(); return *this; }
177 inline SELF operator --() { --entity(); return *this; }
178 };
179 template <typename TEntity>
180 inline PackedEntity< BI_Entity<TEntity>, DILE > PEInit( TEntity &ent ) {
181 return PackedEntity< BI_Entity<TEntity>, DILE >( BI_Entity<TEntity>( ent ) );
182 }
183 template <typename TTarget, typename TEntity>
184 inline PackedEntity<BI_Member<TTarget, TEntity>, DILE> PEInit( const TTarget &target, TEntity TTarget::*member ) {
185 return PackedEntity< BI_Member<TTarget, TEntity>, DILE >( BI_Member<TTarget, TEntity>( const_cast<TTarget &>( target ), member ) );
186 }
187 template <typename TTarget, typename TEntity>
188 inline PackedEntity<BI_Static<TTarget, TEntity>, DILE> PEInit( const TTarget &target, TEntity &ent ) {
189 return PackedEntity< BI_Static<TTarget, TEntity>, DILE >( BI_Static<TTarget, TEntity>( const_cast<TTarget &>( target ), ent ) );
190 }
191
192 #ifdef __acdef_float
193 template <typename BASE, int ID=0> struct _FloatN {
194 BASE val;
195 _FloatN() {}
196 _FloatN(const BASE& v) : val(v) {}
197 operator BASE() const { return val; }
198 };
199 #endif
200 }
201
202 #ifdef __acdef_float
203 typedef AC::_FloatN<float> _Float32;
204 typedef AC::_FloatN<double> _Float32x;
205 typedef AC::_FloatN<long double, 0> _Float64;
206 typedef AC::_FloatN<long double, 1> _Float128;
207 typedef AC::_FloatN<long double, 2> _Float64x;
208 #endif
209
210 #if defined(__acweaving) && defined(__ARM_NEON)
211 typedef __attribute__ ((__neon_vector_type__ (4))) float __Float32x4_t;
212 typedef __attribute__ ((__neon_vector_type__ (2))) double __Float64x2_t;
213 #endif
214 #endif // __cplusplus
215 #endif // __ac_h_
216 class Hello;
217 #endif // __ac_FIRST__home_Tom_aspectcX43X43__
218 #line 219 "main.acc"
219
220 #ifndef __ac_fwd_Hello__
221 #define __ac_fwd_Hello__
222 class Hello;
223 namespace AC {
224 __attribute((always_inline)) inline void invoke_Hello_Hello__a0_before ();
225 }
226 #endif
227
228 #ifndef __ac_need__home_Tom_aspectcX43X43_ah_get_hello_world_ah__
229 #define __ac_need__home_Tom_aspectcX43X43_ah_get_hello_world_ah__
230 #endif
231
232 #line 1 "ah_get/main.cc"
233
234 #line 1 "ah_get/main.cc"
235 #include <iostream>
236
237 char exclamation = '!';
238
239 #line 240 "main.acc"
240
241 template <typename TResult, typename TEntity>
242 __attribute__((always_inline)) inline TResult __Get__Z4mainv_0_0 (TEntity &ent, AC::RT<TResult>){
243 TResult __result_buffer;
244 AC::invoke_Hello_Hello__a0_before ();
245 __result_buffer = ::exclamation;
246 return (TResult &)__result_buffer;
247 }
248
249 #line 5 "ah_get/main.cc"
250
251 #line 5 "ah_get/main.cc"
252 int main(){
253 std::cout << __Get__Z4mainv_0_0< > (exclamation, __AC_TYPEOF((exclamation)) ) << std::endl; //print World String
254 return 0;
255 }
256 #line 257 "main.acc"
257
258 #ifndef __ac_have_predefined_includes__
259 /*** begin of aspect includes ***/
260 // commented out by ac++: #include "hello_world.ah"
261 /*** end of aspect includes ***/
262 #endif
263 #line 9 "ah_get/main.cc"
264
265 #line 9 "ah_get/main.cc"
266
267 #ifdef __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_get_main_cc__
268 #ifdef __ac_need__home_Tom_aspectcX43X43_ah_get_hello_world_ah__
269 #ifndef __ac_have__home_Tom_aspectcX43X43_ah_get_hello_world_ah__
270 #define __ac_have__home_Tom_aspectcX43X43_ah_get_hello_world_ah__
271 // commented out by ac++: #include "hello_world.ah"
272 #line 1 "ah_get/hello_world.ah"
273 #ifndef __WORLD_AH__
274 #define __WORLD_AH__
275
276 // commented out by ac++: #include <iostream>
277 // commented out by ac++: #include <string>
278
279 class Hello {
280 #line 281 "main.acc"
281 public:
282 template <typename, int = 0> struct __BYPASSHello {};
283 template <typename, int> friend struct __BYPASSHello;
284 private:
285 #line 7 "ah_get/hello_world.ah"
286
287 #line 7 "ah_get/hello_world.ah"
288
289
290 public: __attribute__((always_inline)) inline void __a0_before() {
291 //print "Hello" before gettig the "World" String of the World Object
292 std::cout << "Hello World";
293 }
294
295 #line 296 "main.acc"
296
297 public:
298 static Hello *aspectof () {
299 static Hello __instance;
300 return &__instance;
301 }
302 static Hello *aspectOf () {
303 return aspectof ();
304 }
305 private:
306
307 #line 14 "ah_get/hello_world.ah"
308
309 #line 14 "ah_get/hello_world.ah"
310 }
311 #line 312 "main.acc"
312 ;
313 namespace AC {
314 __attribute((always_inline)) inline void invoke_Hello_Hello__a0_before () {
315 ::Hello::aspectof()->__a0_before ();
316 }
317 }
318
319 #line 14 "ah_get/hello_world.ah"
320
321 #line 14 "ah_get/hello_world.ah"
322 ;
323
324 #endif
325 #line 15 "ah_get/main.cc"
326 #endif
327 #endif
328 #undef __ac_FIRST__home_Tom_aspectcX43X43__
329 #undef __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_get_main_cc__
330 #endif // __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_get_main_cc__