Debian Codegraph @

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

raw
1 #line 1 "ah_ref/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_ref_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_ref_hello_world_ah__
229 #define __ac_need__home_Tom_aspectcX43X43_ah_ref_hello_world_ah__
230 #endif
231
232 #line 1 "ah_ref/main.cc"
233
234 #line 1 "ah_ref/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 __Ref__Z4mainv_1_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_ref/main.cc"
250
251 #line 5 "ah_ref/main.cc"
252 int main(){
253 char * exclamation_mark = __Ref__Z4mainv_1_0< > (exclamation, __AC_TYPEOF((&exclamation)) );
254 std::cout << *exclamation_mark << std::endl; //print World String
255 return 0;
256 }
257 #line 258 "main.acc"
258
259 #ifndef __ac_have_predefined_includes__
260 /*** begin of aspect includes ***/
261 // commented out by ac++: #include "hello_world.ah"
262 /*** end of aspect includes ***/
263 #endif
264 #line 10 "ah_ref/main.cc"
265
266 #line 10 "ah_ref/main.cc"
267
268 #ifdef __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_ref_main_cc__
269 #ifdef __ac_need__home_Tom_aspectcX43X43_ah_ref_hello_world_ah__
270 #ifndef __ac_have__home_Tom_aspectcX43X43_ah_ref_hello_world_ah__
271 #define __ac_have__home_Tom_aspectcX43X43_ah_ref_hello_world_ah__
272 // commented out by ac++: #include "hello_world.ah"
273 #line 1 "ah_ref/hello_world.ah"
274 #ifndef __WORLD_AH__
275 #define __WORLD_AH__
276
277 // commented out by ac++: #include <iostream>
278 // commented out by ac++: #include <string>
279
280 class Hello {
281 #line 282 "main.acc"
282 public:
283 template <typename, int = 0> struct __BYPASSHello {};
284 template <typename, int> friend struct __BYPASSHello;
285 private:
286 #line 7 "ah_ref/hello_world.ah"
287
288 #line 7 "ah_ref/hello_world.ah"
289
290
291 public: __attribute__((always_inline)) inline void __a0_before() {
292 //print "Hello" before gettig the "World" String of the World Object
293 std::cout << "Hello World";
294 }
295
296 #line 297 "main.acc"
297
298 public:
299 static Hello *aspectof () {
300 static Hello __instance;
301 return &__instance;
302 }
303 static Hello *aspectOf () {
304 return aspectof ();
305 }
306 private:
307
308 #line 14 "ah_ref/hello_world.ah"
309
310 #line 14 "ah_ref/hello_world.ah"
311 }
312 #line 313 "main.acc"
313 ;
314 namespace AC {
315 __attribute((always_inline)) inline void invoke_Hello_Hello__a0_before () {
316 ::Hello::aspectof()->__a0_before ();
317 }
318 }
319
320 #line 14 "ah_ref/hello_world.ah"
321
322 #line 14 "ah_ref/hello_world.ah"
323 ;
324
325 #endif
326 #line 16 "ah_ref/main.cc"
327 #endif
328 #endif
329 #undef __ac_FIRST__home_Tom_aspectcX43X43__
330 #undef __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_ref_main_cc__
331 #endif // __ac_FIRST_FILE__home_Tom_aspectcX43X43_ah_ref_main_cc__