Implementation of member lookup
Posted: January 16th, 2010 | Author: Mars | Filed under: Progress | Comments OffI’ve checked in the new member-lookup code for objects and modules. The compiler generates a binary search tree, which the object function captures as one of its slots. Request for an object member becomes a call to the BST lookup function. The lookup code is implemented as a compiler intrinsic. I tried to write it as an actual function, which would live in a “core” library, but implementing modules in terms of a module turned out to be something of a challenge.
The next step will be a function to set a value in the tree. This is not the same as the standard associative-container “insert” operation – you can’t establish a new key-value mapping, but only change the value associated with an existing key. This way I can organize the tree at compile time, and the intrinsic member-lookup and member-set functions don’t need any complex balancing logic.