DIRECTORY AMAtom USING [], AMList USING [IsAList], AMBridge USING [TVForReferent], AMTypes USING [Class, Range, UnderType, TVType, TypeClass], Atom USING [PropList, GetPropFromList, PutPropOnList], AtomPrivate USING [AtomRec], SafeStorage USING [EquivalentTypes, GetCanonicalType, GetTypeAttachment, nullType, PutTypeAttachment, Type] ; AMAtomImpl: CEDAR PROGRAM IMPORTS AMBridge, AMList, AMTypes, Atom, SafeStorage EXPORTS AMAtom = BEGIN OPEN Atom, SafeStorage; TypeRecord: TYPE = RECORD[forThis: PropList _ NIL, forRefThis: PropList _ NIL]; -- describes type attachment. . TypePutProp: PUBLIC PROC [type: Type _ nullType, prop: REF ANY, val: REF ANY] = { OPEN AMTypes; underType: Type = UnderType[type]; class: Class = TypeClass[underType]; typeInfo: REF TypeRecord; IF class = ref OR class = list OR AMList.IsAList[underType: underType] THEN { referentType: Type _ GetCanonicalType[Range[type]]; typeInfo _ NARROW[GetTypeAttachment[referentType]]; IF typeInfo = NIL THEN {typeInfo _ NEW[TypeRecord _ []]; PutTypeAttachment[referentType, typeInfo] }; typeInfo.forRefThis _ Atom.PutPropOnList[typeInfo.forRefThis, prop, val]; }; type _ GetCanonicalType[type]; typeInfo _ NARROW[GetTypeAttachment[type]]; IF typeInfo = NIL THEN {typeInfo _ NEW[TypeRecord _ []]; PutTypeAttachment[type, typeInfo] }; typeInfo.forThis _ Atom.PutPropOnList[typeInfo.forThis, prop, val]; }; -- of TypePutProp TypeGetProp: PUBLIC PROC [type: Type _ nullType, prop: REF ANY, dereferenced: BOOLEAN _ FALSE, ref: REF ANY _ NIL] RETURNS[REF ANY] = { typeInfo: REF TypeRecord; IF type = nullType THEN TRUSTED { IF ref # NIL THEN { type _ AMTypes.TVType[AMBridge.TVForReferent[ref]]; dereferenced _ TRUE; } ELSE RETURN[NIL]; }; type _ GetCanonicalType[type]; typeInfo _ NARROW[GetTypeAttachment[type]]; IF typeInfo = NIL THEN RETURN[NIL]; RETURN[Atom.GetPropFromList[IF dereferenced THEN typeInfo.forRefThis ELSE typeInfo.forThis, prop]]; }; -- of TypeGetProp IsAnAtom: PUBLIC PROC [type: Type, dereferenced: BOOLEAN _ FALSE] RETURNS[BOOLEAN] = { -- e.g. if x: TYPE = LIST OF REF ANY, and you obtain a tv for the first element of x, its type is of REF ANY. The only way to find out if this is an atom is to ask whether the type of its referent is the same as that of the type of the range of ATOM. This procedure does that for you. If dereferenced = TRUE, then x is a tv for the referent, and in this case the test is whether the type of x is the type of the range of ATOM. RETURN[EquivalentTypes[IF dereferenced THEN type ELSE AMTypes.Range[type], CODE[AtomPrivate.AtomRec]]]; }; END. >AMAtomImpl.Mesa. Last Modified On May 13, 1983 10:34 am by Paul Rovner Property List Operations for types the following provide property list operations on types. They are included here because this interface is really a combination of atoms and property list operations. and they are used in both streams as well as by the userexec. Note that using them will invoke the runtime type package. if type is a ref type, attach to referent as well, so that if you start with the ref, and therefore can only obtain type for its referent, will still be able to find the type attachment.. IF there were a way of getting to type REF FOO from type FOO, then this would be unnecessary because if you wanted to know whether REF FOO had a type attachment and you had a FOO in hand, you would simply construct that type. Miscellaneous ΚC– "cedar" style˜J˜JšΟc™Jšœ™6J˜šΟk ˜ Jšœžœ˜Jšœžœ ˜Jšœ žœ˜Jšœžœ.˜;Jšœžœ,˜6Jšœ žœ ˜Jšœ žœZ˜k˜J˜——JšΠbl œžœž˜J˜Jšžœ-˜4šžœ ˜J˜—Jšœžœžœ˜headšœ"™"Jšœž™žJ˜Jš Οn œžœžœžœžœ˜oJ˜š  œžœžœ žœžœžœžœ˜RJšžœ ˜ Jšœ"˜"J˜$Jšœ žœ ˜šžœ žœžœ&žœ˜NJšœž™žJšœ3˜3Jšœ žœ"˜3šžœ žœžœ˜Jšœ žœ˜!Jšœ-˜-—J˜IJšœ˜—Jšœ˜Jšœ žœ˜+šžœ žœžœ˜Jšœ žœ˜!Jšœ"˜"Jšœ˜—J˜CJšžœ˜—J˜š  œžœžœ žœžœžœžœžœžœžœžœžœžœž˜ˆJšœ žœ ˜šžœžœ˜"šžœžœž˜J˜3Jšœžœ˜Jšž˜—Jšžœžœžœ˜Jšœ˜—Jšœ˜Jšœ žœ˜+Jš žœ žœžœžœžœ˜#Jšžœžœžœžœ˜cJšžœ˜——šœ ™ š œžœžœžœžœžœžœ˜WJšͺ˜ͺJš žœžœžœžœžœ˜gJšœ˜—J˜—Jšžœ˜J˜J˜J˜—…— ™