From: Yann D. <yd...@us...> - 2003-09-15 12:54:46
|
On Mon, Sep 15, 2003 at 08:53:28AM +0800, Grzegorz Jakacki wrote: > Why not something like this: > > class MyWalker : public Walker > { > public: > Ptree* TranslateCast(Ptree* exp) > { > Ptree exp2 = BeforeTranslateCast(exp); > Ptree* e = exp2->Nth(3); > Ptree* e2 = AfterTranslateCastedExpression(Translate(BeforeTranslateCastedExpression(e))); > return AfterTranslateCast(new PtreeCastExpr(TranslateCastType(exp2->First()), > Ptree::ShallowSubst(e2, e, exp2->Cdr()))); > } > > ... BeforeTranslateCast(...) { ... } > ... AfterTranslateCastedExpression(...) { ... } > ... AfterTranslateCast(...) { ... } > }; > > AFAIU you get the same result without adding a hook. Yes, but that makes a modified copy of the original code, and will require updating to take advantage of any changes in the original... > Looks like we came to similar conclusions. > > The code that I wrote above works, but it violates Liskov Substitution > Principle --- the user cannot be sure about the behaviour of member > function 'TranslateCast()' when it is called via Walker*. Hm - what assumptions of Walker would this code break ? Regards, -- Yann Dirson <yd...@al...> | Why make M$-Bill richer & richer ? Debian-related: <di...@de...> | Support Debian GNU/Linux: Pro: <yan...@fr...> | Freedom, Power, Stability, Gratuity http://ydirson.free.fr/ | Check <http://www.debian.org/> |