|Jump tables and OOP in Oberon firstname.lastname@example.org (1996-07-13)|
|Re: Jump tables and OOP in Oberon email@example.com (Tim Dwyer) (1996-07-18)|
|Re: Jump tables and OOP in Oberon firstname.lastname@example.org (1996-07-22)|
|Re: Jump tables and OOP in Oberon email@example.com (1996-07-23)|
|Re: Jump tables and OOP in Oberon firstname.lastname@example.org (Darius Blasband) (1996-07-23)|
|From:||email@example.com (Robert A Duff)|
|Date:||22 Jul 1996 10:49:51 -0400|
|Organization:||The World Public Access UNIX, Brookline, MA|
Ram Meenakshisundaram <firstname.lastname@example.org> 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;
or something like that.
Each object points to its type descriptor, which contains the above
Return to the
Search the comp.compilers archives again.