Re: Jump tables and OOP in Oberon (Robert A Duff)
22 Jul 1996 10:49:51 -0400

          From comp.compilers

Related articles
Jump tables and OOP in Oberon (1996-07-13)
Re: Jump tables and OOP in Oberon (Tim Dwyer) (1996-07-18)
Re: Jump tables and OOP in Oberon (1996-07-22)
Re: Jump tables and OOP in Oberon (1996-07-23)
Re: Jump tables and OOP in Oberon (Darius Blasband) (1996-07-23)
| List of all articles for this month |

From: (Robert A Duff)
Newsgroups: comp.compilers
Date: 22 Jul 1996 10:49:51 -0400
Organization: The World Public Access UNIX, Brookline, MA
References: 96-07-083
Keywords: code

Ram Meenakshisundaram <> wrote:
>... Can someone clearly define how jump tables are used in
>pascal-type CASE statements?

The compiler first checks that the case labels are "reasonably" close
together. If so, generate an array, indexed by the case expression, of
code addresses to jump to.

If the case labels are not reasonably close together, it's better to
generate a table of code addresses that can be binary-searched.

And if there are just a couple of case labels, treating it like a series
of if-then-else's makes sense.

> IS(x, A)
>How can this be implemented the most efficent way? I was think about creating
>a pointer for each Object. Each pointer Object will point to its parent.
>Each Object variable would have a pointer to its Object pointer. To determine
>if a variable is of type X, one only needs to traverse through the object
>tree and see if the variable's object pointer is the same as the one specified
>in the IS command.

The technique I've seen Ada compilers do is: For each type, keep an
array of (pointers to) all the ancestors of that type. Also keep an
integer number representing the depth of that type in the hierarchy.
Then, you can check whether a given type is in another type in constant
time -- no need to loop through all the parents. Just do:

        if this type is deeper than that type then
                check if the N'th element of the array is that type;
        end if;

or something like that.

Each object points to its type descriptor, which contains the above

- Bob

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.