Dealing with InheritanceTopStructure of Semantic Processing CodeHandling Qualified Method Invocations

Handling Qualified Method Invocations

  1. The scheme I have described does not handle the processing of invocations of the form:
           obj . M ( arguments ) 
          

  2. When the semantic processor encounters a subtree corresponding to a selection like:
    
              obj . M
    	
    it needs some way to locate a binding that associates the name M with the appropriate declaration descriptor for the method (It can't just look on the top of the stack hanging off of M's identifier descriptor).

  3. The key to qualified method component names is to realize that a method name alone is potentially ambiguous. Only when paired with some particular class can a component name be interpreted unambiguously. Thus, there should be one declaration descriptor (and one binding?) for each 'structure type/component name' pair.

  4. There are many ways to solve this problem.
    Approach 1
    We will already have a linked list of method declaration descriptors pointed to by each class' declaration descriptor. To process x.M do a linear search for "M" in the linked list attached to the declaration descriptor for x's class.

    This is simple, but linear lookup may not be efficient enough.

    Approach 2
    Hang a hash table of field declaration descriptors off of each class' declaration descriptor (or an AVL tree or a ...).

    This will tend to be complicated and space inefficient.

    Compromise Approach
    Employ a single dictionary structure (hash table or binary tree) in which the search keys are class/ method name pairs.

    • The keys used to look up items in this table will actually be pairs composed of a pointer to the class' declaration descriptor and a pointer to the method name's identifier descriptor.

    • The semantic processor will have access to both parts of the needed pair when it processes a selection like obj.M.

    • We will use a hash table for this purpose
    • Note that we will have to add a distinct entry to this hash table for every class by which a method is inherited.

  5. Overview of required processing:

Computer Science 434
Department of Computer Science
Williams College

Dealing with InheritanceTopStructure of Semantic Processing CodeHandling Qualified Method Invocations