Possible Eiffel code transformations to implement the "reasonable semantics"

Thanks to Roger Rousseau, Université de Nice.

Up, Top, Middle and Bottom classes are unchanged
Transformations are localized in Down class (essential for incremental compilation).
Client

EiffelStudio 5.x used



class UP

feature

        cv(t: TOP) is
                do
                        io.put_string("cv(TOP) in UP (type effectif de t : ")
                        io.put_string(t.generating_type)
                        io.put_string(")%N")
                end

        ctv(b: BOTTOM) is
                do
                        io.put_string("ctv(BOTTOM) in UP (type effectif de b : ")
                        io.put_string(b.generating_type)
                        io.put_string(")%N")
                end

end -- class UP



class DOWN

inherit
        UP
                rename cv as cv_up, ctv as ctv_up
                undefine ctv_up
                end
        UP
                rename ctv as ctv_up
                redefine  cv, ctv_up
                select cv
                end

feature

        cv(m: TOP) is
                -- pas de redéfinition covariante de CV issu de UP
                -- pour avoir plus de liberté et sans violer les règles
                do
                        if m.generating_type.is_equal("TOP") then
                                cv_up(m)
                        else
                                io.put_string("cv(MIDDLE) in DOWN (type effectif de m : ")
                                io.put_string(m.generating_type) -- passe avec estudio
                                io.put_string(")%N")
                        end
                end

      ctv(m: MIDDLE) is
            -- Ceci N'EST PAS une redéfinition contravariante, mais une nouvelle définition
            -- (une redéfinition contravariante est interdite en Eiffel)
                do
                        io.put_string("ctv(MIDDLE) in DOWN (type effectif de m : ")
                        io.put_string(m.generating_type)
                        io.put_string(")%N")
                end

      ctv_up(b: BOTTOM) is
                do
                        ctv(b);
                end

end -- class DOWN



class TOP

end -- class TOP



class MIDDLE

inherit TOP

end -- class MIDDLE



class BOTTOM

inherit MIDDLE

end -- class BOTTOM


indexing
 

        description    : " test des redéfinitions (article de Beugnard / LMO2002) "
        creation_date  : " Sat Dec 29 12:46:45 2001 "
        version        : " $Id 1.1$ "
        author         : " Roger Rousseau <rr@unice.fr> "
        organization   : " University of Nice (UNSA) / I3S lab (UMR 6070 CNRS) "

class T_REDEFINITION

creation make

feature -- objets récepteurs

        u  : UP
        ud : UP
        d  : DOWN
        t  : TOP
        m  : MIDDLE
        b  : BOTTOM

feature -- test

        make is
                do
                        !! t ; !! m ; !! b
                        premier_test
                        deuxieme_test
                        troisieme_test
                end -- t_main

        premier_test is
                -- u est vraiment un UP
                do
                        io.put_string("%Npremier_test : u est vraiment un UP ---------------------------%N%N")
                        !! u

                        io.put_string("u1 - u.cv(t) => "); u.cv(t)
                        io.put_string("u2 - u.cv(m) => "); u.cv(m)
                        io.put_string("u3 - u.cv(b) => "); u.cv(b)

                        io.put_string("u4 - u.ctv(t) => TOP not BOTTOM (compilation)%N");    -- u.ctv(t)
                        io.put_string("u5 - u.ctv(m) => MIDDLE not BOTTOM (compilation)%N"); -- u.ctv(m)
                        io.put_string("u6 - u.ctv(b) => "); u.ctv(b)
                end -- premier_test

        deuxieme_test is
                -- d est vraiment un DOWN
                do
                        io.put_string("%Ndeuxième_test : d est vraiment un DOWN ------------------------%N%N")
                        !! d

                        io.put_string("d1 - d.cv(t) => "); d.cv(t)
                        io.put_string("d2 - d.cv(m) => "); d.cv(m)
                        io.put_string("d3 - d.cv(b) => "); d.cv(b)

                        io.put_string("d4 - d.ctv(t) => TOP not MIDDLE (compilation)%N"); -- d.ctv(t)
                        io.put_string("d5 - d.ctv(m) => "); d.ctv(m)
                        io.put_string("d6 - d.ctv(b) => "); d.ctv(b)

                end -- deuxieme_test

        troisieme_test is
                -- ud est effectivement un DOWN
                do
                        io.put_string("%Ntroisième_test : ud est effectivement un DOWN -----------------%N%N")
                        !DOWN! ud

                        io.put_string("ud1 - ud.cv(t) => "); ud.cv(t) -- provoque une erreur avec SmallEiffel
                        io.put_string("ud2 - ud.cv(m) => "); ud.cv(m)
                        io.put_string("ud3 - ud.cv(b) => "); ud.cv(b)

                        io.put_string("ud4 - ud.ctv(t) => TOP not BOTTOM (compilation)%N"); -- ud.ctv(t)
                        io.put_string("ud5 - ud.ctv(m) => MIDDLE not BOTTOM (compilation)%N"); -- ud.ctv(m)
                        io.put_string("ud6 - ud.ctv(b) => "); ud.ctv(b)

                end -- troisieme_test

end -- class T_REDEFINITION


system
        test_redefinition
 

root
        T_REDEFINITION: "make"
 

default
        assertion (require)
        multithreaded (no)
        console_application (no)
        dynamic_runtime (no)
        dead_code_removal (yes)
        profile (no)
        line_generation (no)
        array_optimization (no)
        inlining (no)
        inlining_size ("10")
 

cluster

        root_cluster: "."
 

                -- EiffelBase
                library base:                           "$ISE_EIFFEL/library/base"
                exclude
                        "table_eiffel3";"desc"
                end
end