Contents
Page-10
Prev
Next
Page+10
Index
Static Method Lookup
In a static language, all of the methods defined for each class can
be determined at compile time. Lookup of the called routine can then
be done efficiently:
- Selector names are converted to integer offsets.
- A class is implemented during execution as an array of method
addresses ( virtual method table (VMT) or vtable).
- A method call obj.sel(args) is executed by:
- Getting the class pointer from obj
- Using the offset associated with sel to look up the
method address in the method table of the class
- Calling the method.
This takes only a few instructions more than an ordinary function call.
This technique is used in C++.