p — ► M C re a tio n
l-'igure 4..S: O b ject, la y o u t in Ig u a n a . R e fle c tiv e o b je c ts are associated w ith a n u m l)e r o f m e ta o b je c ts , each o f w h ic h rep re sen ts s tr u c tu r a l o r b e h a v io u ra l aspects o f th e o b je c t . M u ltip le m e ta o b je c ts re p re s e n tin g th e sam e a spect are chained in a lin k e d lis t.
Ill c o n tra s t, to th e ]>revious im p le m e n ta tio n o f th e Ig ua na m e ta -le v e l class h ie ra rc h y , we to o k a r liffe r e iit a p p ro a c h in b in d in g o b je c ts to th e ir m e ta -le v e l re p re s e n ta tio n . In th e p re v io u s ve rs io n , base-level o b je c ts c o n ta in e d a sing le ])o in te r, th e so-called m e? «-])oin ter, to tJ ie ir m e ta -le v e l re p re s e n ta tio n . T h e ra tio n a le b e h in d th is design was to a llo w a fa s t and easy tr a n s itio n fro m one m e ta -le v e l re p re s e n ta tio n to a n o th e r by s im p ly re -d ire c tin g
th e in e ta -p o in te r.
Mainly because of p erfo rm a n c e reasons we found th e previous design was disad v an ta g eo u s: in o rd e r to access m e ta o b je c ts , an a d d itio n al level of indirection has to be overcome. T h is overhead becom es significant when perform ing reified o p e r a tio n s on o b je c ts such as s t a t e read an d s t a t e write.
We believe t h a t d u rin g t h e life-cycle of an o b je c t th e n u m b e r of base-level o p e r a tio n s exceed the n u m b e r of meta-level re configura tions by far. In our design we there fore focused on allowing a fast tr a n s itio n from base to meta-level c o m p u ta tio n s by m inim ising th e n u m b e r of indirections. M oreover, sw itching to a different meta-level re p re s e n ta tio n by sim ply re directing th e m e ta - p o in te r has shown to be a very unsafe o p e r a tio n since som e s o r t of c o m p a tib ility between th e old and new configuration is required. For exa m ple , it is not m eaningful to replace an o b j e c t ’s en tire s t r u c t u r a l info rm atio n w ith one t h a t does not reflect t h e o b j e c t ’s a c tu a l type.
4.4
T h e P r e - P r o c e s s o r
in th e pre-processing ]:>hase th e Ig u a n a e x ten d e d source-code is parsed and tr a n s la te d into s t a n d a r d C+ + . P a rsin g is tra d itio n a lly carried out in various sta g e s ([ASU86]):
1. Lexical analysis: th e c h a r a c te r s tr e a m of th e source-code is sca nned an d grou|)ed into tokens
2. S y n ta c tic a l analysis: th e token s tr e a m g e n e ra te d d u rin g th e lexical analysis is parsed an d groui'jed into g r a m m a tic a l phrases.
3. .Abstract S y n ta x Tree g ene ration: d u rin g th e s y n ta c tic a l analysis an A b s t r a c t S y n t a x Tree (A ST) is g e n e ra te d t h a t re p resen ts th e g r a m m a tic a l p h ra ses of th e source p ro g ra m .
I. S e m a n tic analysis and .‘VST modification: in a last s te p th e .>\S1' g e n e ra te d d u rin g th e s y n ta c tic a l analysis is walked and tra n s f o rm e d by th e pa rse r to synthesise th e ti'anslated soui’ce code.
.A n u m b er of tools exist t h a t a u t o m a t e th e ])rocess of p arser w riting. We chosed to use th e PC'C'TS |)arser g e n e r a to r ([Par96]) as it is freely available an d com es with a (fairly) com])lete C++ g r a m m a r . It g e n e ra te s a recursive descent ])arser from th e g r a m m a r d e scription. T h e g r a m m a r itself is w'rit ten in E B N F -fo rm and can be a n n o t a t e d to guide t he a u t o m a t e d .A ST-construction and .A S T -transform a tion.
4.5
S oiirce-to -S o iirce T ranslation
III t h i s s e c t i o n we | ) r e s e nt a d e t a i l e d descri ])t i on of t h e c o d e m o d i f i c a t i o n s t h a t a r e c a rr ie d o u t by t h e I g u a n a p r e - p r o c e s s o r .