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:
This takes only a few instructions more than an ordinary function call.
This technique is used in C++.
- Selector names are converted to integer offsets.
- A class is implemented during execution as an array of method addresses.
- A method call obj.sel(args) is executed by:
- Getting the class pointer from obj
- Adding the offset associated with sel
- Getting the method address from that address
- Calling the method.