TAMARIN CLASS SYSTEM Every piece of datum in Tamarin Memory will be a member of a class. The handle used to identify a class is called a class wrapper. A pointer to a class wrapper is the primary entity used by the opcodes dealing with classes. The class of an item is determined by one of several means. The first way is to use the tag & type bits of the item to index into the class table of the system. The class table contains pointers to the class wrappers of all of the immediate data formats, along with the class wrappers of the untyped pointers. The class of typed pointers is determined by fetching the class wrapper of the object pointed to, which is located in the word preceeding the object in memory. Type numbers, indexes, and names are obsolete notions, and all "typing" will be performed with the class system. All objects (both user defined & built in) will be of some class, with the class T being the superclass of all objects. The class system consists of class objects, class wrappers, and class names. Class Objects All objects in the system are class objects, since every object has a class describing it. The class of an object is found via the class table or the object's wrapper pointer. Class Wrappers The handle used by the processor when performing class operations is a class wrapper. The class wrapper contains a pointer to the actual class, along with a list of all of the class wrappers which are superclasses of the class. Thus only the wrapper is needed to determine if an object is of a particular class, since both the wrapper itself, and all of the super classes are contained in the wrapper. Class Names Every class in the system is assigned a name when the class is created. This name is the user's handle for the class. The compiler or interpreter must transform this handle into the actual class wrapper when an objects class is being compared to it. The opcodes provided in the Tamarin processor for dealing with the class system include: INSTANCEP, INSTANCECLASSP, Method Lookup, CLASSWRAPPER, and SLOTACCESS. The semantics of the opcodes are: CLASSWRAPPER Where Used: Semantics: Given an object at Tos, return the class wrapper for the object. The tag and subtype bits of the Tos object are checked to determine if the object is one which contains its wrapper in the object header (either an instance of class or structure). If so, then the wrapper if fetched from the header of the object. Otherwise the tag & subtype bits are used to index into the Wrapper table, where the wrapper for the object can be found. INSTANCEP Where Used: Semantics: This opcode is used to determine if an object is an instance of a particular class. The class wrapper of the Tos object is checked for EQ to the IBufData word (which contains the class wrapper of the desired class). If a match is not found, the super wrapper list of Tos's wrapper is scanned, to determine if the desired class is a superclass of Tos's class. INSTANCECLASSP Where Used: Semantics: This opcode operates the same as INSTANCEP, except the IBufData word contains a pointer to the class instead of the class wrapper. The class wrapper must first be found from the class, then the class wrappers are comapred as in the INSTANCEP opcode. SLOTACCESS Where Used: Used in Methods to access the slots of an instance--class. Semantics: Fetch the slot indcated in the alpha byte out of the object at Tos. The offset into the slots is found by using the alpha byte to index into the permutation vector, to get the actual slot offset, and then using that offset to fetch the actual value of the slot. What of SLOTSTORAGE? METHOD LOOKUP Where Used: During function call. Semantics: Determine the correct method to call during a function call. When the function definition cell is a is a pointer to a MethodP, then a method lookup must take place. The lookup proceeds by first computing the wrappers of the parameters (up to n parameters), and producing a hash value which is used to index into the method lookup table. The individual wrappers of the parameters are then compared with the hashed table entry, and if all match the corresponding permutation vector and code pointer are used to perform the function call. If a match is not found at the hash entry the overflow table is searched sequentially, to find a possible match there. If a match is still not found, then the Ufn routine is called to resolve the lookup. GACHA ?1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) E Ô ‡ u„ zº