DIRECTORY Rope USING [ROPE], SafeStorage USING [Type, nullType], WorldVM USING [World]; AMTypes: CEDAR DEFINITIONS = BEGIN OPEN Rope, WorldVM; Type: TYPE = SafeStorage.Type; nullType: Type = SafeStorage.nullType; TypedVariable: TYPE = REF ANY; TV: TYPE = TypedVariable; Status: TYPE = {mutable, readOnly, const}; Index: TYPE = NAT; Class: TYPE = { definition, cardinal, longCardinal, integer, longInteger, real, character, atom, rope, list, ref, pointer, longPointer, descriptor, longDescriptor, basePointer, relativePointer, procedure, signal, error, program, port, enumerated, subrange, union, sequence, record, structure, array, countedZone, uncountedZone, nil, unspecified, process, type, opaque, any, globalFrame, localFrame }; Error: ERROR[ reason: ErrorReason, msg: ROPE _ NIL, type: Type _ nullType, -- used with TypeFault, IncompatibleTypes otherType: Type _ nullType -- used with IncompatibleTypes ]; ErrorReason: TYPE = { noSymbols, -- msg has moduleName notImplemented, -- mostly DefaultInitialValue cases incompatibleTypes, -- raised by Assign rangeFault, -- e.g. empty subrange, Apply bounds check notMutable, -- raised by (e.g.) Assign internalTV, -- raised by (e.g.) RefFromTV badName, -- raised by NameToIndex badIndex, -- raised by (e.g.) IndexToType typeFault -- general applicability violation }; Size: PROC [type: Type, length: CARDINAL _ 0] RETURNS [words: INT]; DefaultInitialValue: PROC [type: Type] RETURNS [TV]; IndexToDefaultInitialValue: PROC [type: Type, index: Index] RETURNS [TV]; TypeClass: PROC [type: Type] RETURNS [Class]; UnderClass: PROC [type: Type] RETURNS [Class]; IsPainted: PROC [type: Type] RETURNS [BOOL]; TVType: PROC [tv: TV] RETURNS [Type]; TVStatus: PROC [tv: TV] RETURNS [Status]; TVSize: PROC [tv: TV] RETURNS [words: INT]; GetEmptyTV: PROC RETURNS [TV]; New: PROC [type: Type, status: Status _ mutable, world: World _ NIL, tag: TV _ NIL] RETURNS [TV]; Copy: PROC [tv: TV] RETURNS [TV]; Assign: PROC [lhs, rhs: TV]; AssignNew: PROC [lhs, rhs: TV]; TVEq: PROC [tv1, tv2: TV] RETURNS [BOOL]; TVEqual: PROC [tv1, tv2: TV] RETURNS [BOOL]; NComponents: PROC [type: Type] RETURNS [Index]; VariableType: PROC [type: Type] RETURNS [v: Type, c: Class]; IndexToTV: PROC [tv: TV, index: Index] RETURNS [TV]; IndexToType: PROC [type: Type, index: Index] RETURNS [Type]; NameToIndex: PROC [type: Type, name: ROPE] RETURNS [CARDINAL]; IndexToName: PROC [type: Type, index: CARDINAL] RETURNS [ROPE]; TVToType: PROC [tv: TV] RETURNS [Type]; TVToName: PROC [tv: TV] RETURNS [ans: ROPE]; Tag: PROC [tv: TV] RETURNS [TV]; Variant: PROC [tv: TV] RETURNS [TV]; IsOverlaid: PROC [type: Type] RETURNS [BOOL]; IsMachineDependent: PROC [type: Type] RETURNS [BOOL]; Domain: PROC [type: Type] RETURNS [Type]; Range: PROC [type: Type] RETURNS [Type]; IsPacked: PROC [type: Type] RETURNS [BOOL]; IsComputed: PROC [type: Type] RETURNS [BOOL]; Apply: PROC [mapper: TV, arg: TV] RETURNS [TV]; Length: PROC [tv: TV] RETURNS [INT]; Fetch: PROC [tv: TV, index: INT] RETURNS [CHAR]; Referent: PROC [tv: TV, base: TV _ NIL] RETURNS [TV]; ConcreteRef: PROC [tv: TV] RETURNS [TV]; ReferentStatus: PROC [type: Type--address (not basePointer, atom)--] RETURNS [Status]; IsRefAny: PROC [type: Type] RETURNS [BOOL]; IsInterface: PROC [type: Type] RETURNS [BOOL]; IsAtom: PROC [tv: TV] RETURNS [BOOL]; IsRope: PROC [tv: TV] RETURNS [BOOL]; IsNil: PROC [tv: TV] RETURNS [BOOL]; IsOrdered: PROC [type: Type] RETURNS [BOOL]; PropertyList: PROC [tv: TV] RETURNS [TV]; Coerce: PROC [tv: TV, targetType: Type] RETURNS [TV]; TypeToName: PROC [type: Type, moduleName: REF ROPE _ NIL, fileName: REF ROPE _ NIL] RETURNS [ROPE]; Ground: PROC [type: Type] RETURNS [Type]; GroundStar: PROC [type: Type] RETURNS [Type]; UnderType: PROC [type: Type] RETURNS [Type]; InRange: PROC [type: Type, groundTV: TV] RETURNS [BOOL]; First: PROC [type: Type] RETURNS [TV]; Last: PROC [type: Type] RETURNS [TV]; Next: PROC [tv: TV] RETURNS [TV]; Prev: PROC [tv: TV] RETURNS [TV]; NValues: PROC [type: Type] RETURNS [INT]; Value: PROC [type: Type, index: CARDINAL] RETURNS [TV]; StaticParent: PROC [tv: TV] RETURNS [TV]; Locals: PROC [tv: TV] RETURNS [TV]; EnclosingBody: PROC [tv: TV] RETURNS [TV]; Argument: PROC [tv: TV, index: Index] RETURNS [TV]; Result: PROC [tv: TV, index: Index] RETURNS [TV]; Procedure: PROC [tv: TV--localFrame--] RETURNS [TV--procedure--]; Signal: PROC [tv: TV--catch frame--] RETURNS [TV--signal descriptor--]; IsCatch: PROC [tv: TV] RETURNS [BOOL]; DynamicParent: PROC [tv: TV] RETURNS [TV]; GlobalParent: PROC [tv: TV] RETURNS [TV]; Globals: PROC [tv: TV] RETURNS [TV]; END. &jAMTypes.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Rovner, July 22, 1983 2:39 pm Russ Atkinson (RRA) February 12, 1985 1:19:31 pm PST Notation for procedure comments domain: classExpr B {class1, class2, ...} will raise Error[typeFault] if violated T Y P E S A TV (or TypedVariable) represents a CedarMesa variable. That is, the variable has a certain amount storage, the variable has a type, and it holds a value. There can be numerous variables for a given TV. A TV does NOT provide monitored or otherwise atomic access to its variable, so the user must synchronize uses of TVs. The three kinds of status are: mutable - the variable can have its value changed through this TV readOnly - the variable can NOT have its value changed through this TV const - the variable has constant contents (as for a literal) index range for records, enumerations, etc is [1..n], 0 has special case meaning TypeClass[CODE[T]] where T: TYPE = ... basic types - e.g. TypeClass[CODE[INT]] address types - e.g. TypeClass[CODE[REF INT]] transfer types - e.g. TypeClass[CODE[PROC]] e.g. TypeClass[CODE[{red, green, blue}]] e.g. TypeClass[CODE[ [0..4) ]] the variant parts of record types e.g. TypeClass[CODE[ RECORD[INT] ]] note: structure types are unpainted record types e.g. TypeClass[CODE[ARRAY T1 OF T2]] TypeClass[CODE[ZONE]], TypeClass[CODE[UNCOUNTED ZONE]] TypeClass[TVType[NIL]] TypeClass[CODE[UNSPECIFIED]] or TypeClass[CODE[LONG UNSPECIFIED]] TypeClass[CODE[PROCESS]] TypeClass[CODE[TYPE]] UnderClass[CODE[T]], where T: TYPE; or T: TYPE[2] TypeClass[Range[CODE[REF ANY]]] all global frames have the same type and class all local frames have the same type and class E R R O R S P R O C E D U R E S Access to general Type characteristics. ... returns the # of words for the given type. For sequences only, the # of elements must be supplied as well. For unions, the max # of words will be returned. ... returns the default initialization for the type. This is useless for record components, since the default initialization is usually associated with the component instead of the type, so use IndexToDefaultInitialValue instead in that case. There are a lot of initial values that the compiler can handle but AMTypes cannot handle, especially initialization to variables or procedure calls (can raise Error[notImplemented]). domain: UnderClass[type] B {record, structure} ... returns the initial value associated with the given component of the type. Returns the class of the type. Equivalent to TypeClass[UnderType[type]]. Enumerated types and records declared in interfaces are painted. Access to general TV characteristics. returns the type of the variable represented by the given TV returns the status of the given TV returns the # of words for the given TV returns a predefined, special TV that is used to indicate the "empty" value. The user should only depend on the identity of this TV, NOT the type, status, or size of the returned TV. The procedures below are applicable to all but the frame types, opaque and any. domain: UnderClass[type] N {opaque, any, globalFrame, localFrame} ... creates and returns a cleared object of a give type for the given world (if remote, this is a copied remote object). tag has meaning only for union or sequence-containing record types. See DefaultInitialValue. If world = NIL, then WorldVM.LocalWorld[] is used. domain: UnderClass[TVType[type]] N {opaque, any, globalFrame, localFrame} ... returns a copy of the TV (in the same world). This generates a new variable. The returned TV will have mutable status. domain: UnderClass[TVType[lhs]] N {any, globalFrame, localFrame} domain: UnderClass[TVType[rhs]] N {any, globalFrame, localFrame} ... assigns the value of rhs to lhs; will raise Error[notMutable] if TVStatus[lhs] # mutable ... assigns the value of rhs to lhs for initialization only; will raise Error[notMutable] if TVStatus[lhs] # mutable TVEqual[tv1, tv2] iff assignment to one is equivalent to assignment to the other; i.e, they address the same bits. TVEqual[tv1, tv2] iff the values have the same size and same bits. NOTE: no type checking is done. Procedures with applicability restrictions (based on Class, noted as comments) domain: UnderClass[type] B {record, structure} ... returns the # of components for the type domain: UnderClass[type] B {record, structure} result: c B {nil, union, sequence} returns the union or sequence type and its class (nil if type is not a variant type) domain: UnderClass[TVType[tv]] B {record, structure} range restriction: index IN [1..NComponents[TVType[tv]]] domain: UnderClass[type] B {record, structure, union} ... returns the specified component of the type (SPECIAL CASE for union types: index = 0 gets you the tag type domain: UnderClass[type] B {record, structure, union, enumerated} ... returns the name associated with the given component (raises Error[badName] if no such named component) domain: UnderClass[type] B {record, structure, union, enumerated} ... returns the name associated with the given component (SPECIAL CASE for union types: index = 0 gets you the tag name) domain: UnderClass[TVType[tv]] = type ... returns the type that tv holds (NOT the type of the value that TV holds) class restriction: UnderClass[TVType[tv]] B {ref, atom, rope, enumerated, program, procedure, signal, error, globalFrame} domain: UnderClass[TVType[tv]] = union returns the tag for the given union domain: UnderClass[TVType[tv]] = union returns a TV for the bound variant domain: UnderClass[type] = union domain: UnderClass[type] B {record, structure, union, enumerated, sequence} domain: UnderClass[type] B {array, sequence, procedure, signal, process, address} (not atom, rope) if type = CODE[ARRAY T1 OF T2], Range[type] = CODE[T1] domain: UnderClass[type] B {array, sequence, procedure, signal, process} if type = CODE[ARRAY T1 OF T2], Range[type] = CODE[T2] domain: UnderClass[type] B {array, sequence} domain: UnderClass[type] B {union, sequence} domain: UnderClass[TVType[mapper]] B {array, sequence, descriptor, longDescriptor} domain: UnderClass[TVType[tv]] B {sequence, rope} For a rope, Length returns an INT for the number of characters in the given rope. For a sequence, Length returns an INT specifying the (max) number of elements in the sequence. Use Tag[tv] to obtain the actual sequence tag field. Their values may differ if the tag type has a non-zero lower bound. domain: UnderClass[TVType[tv]] B {rope} For either local or remote ropes, performs the Fetch operation. domain: UnderClass[TVType[tv]] B {ref, list, pointer, longPointer, relativePointer} note: base # NIL iff UnderClass[TVType[tv]] = relativePointer returns a TV for the referent of the address ( domain: UnderClass[TVType[tv]] = ref ConcreteRef returns a TV for the REF . NIL -> NIL. ConcreteRef is implemented only for REFs that are really ATOM, LIST or ROPE guys (Error[reason: notImplemented] is raised otherwise) domain: UnderClass[type] B {atom, rope, list, ref, pointer, longPointer, descriptor, longDescriptor, basePointer, relativePointer} domain: UnderClass[type] B {atom, list, ref, rope} domain: UnderClass[type] B {record, structure} domain: UnderClass[TVType[tv]] B {atom, ref} domain: UnderClass[TVType[tv]] B {ref, rope} domain: UnderClass[TVType[tv]] B {atom, rope, list, ref, pointer, longPointer, descriptor, longDescriptor, basePointer, relativePointer} domain: UnderClass[type] B {basePointer, relativePointer} domain: UnderClass[TVType[tv]] B {atom} gets the property list for an ATOM use Coerce to Narrow or Widen IF name exists and REFs to moduleName and/or fileName ROPEs are provided, TypeToName provides that info too. peels off one layer of definition peels off all layers of definition and subrange returns first non-definition type domain: UnderClass[type] B {subrange} tests to make sure that the value in groundTV is in the range given by type domain: UnderClass[type] B {enumerated, subrange, basic} domain: UnderClass[type] B {enumerated, subrange, basic} domain: UnderClass[TVType[tv]] B {enumerated, subrange, basic} returns NIL if no next domain: UnderClass[TVType[tv]] B {enumerated, subrange, basic} returns NIL if no next domain: UnderClass[type] B {enumerated} domain: UnderClass[type] B {enumerated} index range is [1..NValues[type]] domain: UnderClass[TVType[tv]] B {procedure} returns the static parent (enclosing procedure) for the given procedure (will return NIL for an outer-level procedure) Access to local and global frames domain: UnderClass[TVType[tv]] B {localFrame} returns the record for the variables in the given local frame (NIL if no such variables) domain: UnderClass[TVType[tv]] B {localFrame} returns the enclosing body for the given local frame (NIL if at the outer level) domain: UnderClass[TVType[tv]] B {localFrame} returns the given argument for the given local frame domain: UnderClass[TVType[tv]] B {localFrame} returns the given result for the given local frame domain: UnderClass[TVType[tv]] B {localFrame} returns the procedure for the given local frame (raises Error[typeFault] if the frame is for a catch phrase) domain: UnderClass[TVType[tv]] B {localFrame} returns the catch phrase for the given local frame (raises Error[typeFault] if the frame is for a procedure) domain: UnderClass[TVType[tv]] B {localFrame} ... returns TRUE iff the TV is for a catch frame (and therefore should work if given to Signal). This is useful when trying to print a local frame. domain: UnderClass[TVType[tv]] B {localFrame} returns the next elder local frame in the call chain (NIL if at the process base) domain: UnderClass[TVType[tv]] B {localFrame, procedure} returns the global frame for the given local frame domain: UnderClass[TVType[tv]] B {globalFrame} returns the global variable record for the given global frame Κf– "cedar" style˜codešœ ™ Kšœ Οmœ1™˜>Kšœžœžœ™'—šœUΟcœ˜fKšœžœžœžœ™-—šœ(˜(Kšœ žœžœ™+—šœ ˜ Kšœžœ™(—šœ ˜ Kšœžœ ™—šœ˜Kšœ!™!—šœ˜Kšœžœžœžœ™#K™0—šœ˜Kšœžœžœžœ™$—šœ˜Kš œ žœžœžœžœ™6—šœ˜Kšœžœ™—šœ ˜ Kš œ žœž œžœžœž œ™A—šœ˜Kšœ žœžœ™—šœ˜Kšœ žœžœ™—šœ˜Kš œ žœžœ žœžœžœžœ™2—šœ˜Kšœžœžœžœ™—šœ˜K™.K™-—Kšœ˜——K™–2.5 in tabStopsšœ ™ K–2.5 in tabStops™–2.5 in tabStopsšœžœ˜ K–2.5 in tabStopsšœ˜K–2.5 in tabStopsšœžœžœ˜K–2.5 in tabStopsšœŸ)˜@K–2.5 in tabStopsšœŸ˜9K–2.5 in tabStopsšœ˜—–2.5 in tabStopsšœ žœ˜K–2.5 in tabStopsšœ Ÿ˜ K–2.5 in tabStopsšœŸ#˜3K–2.5 in tabStopsšœŸ˜&K–2.5 in tabStopsšœ Ÿ*˜6K–2.5 in tabStopsšœ Ÿ˜&K–2.5 in tabStopsšœ Ÿ˜)K–2.5 in tabStopsšœ Ÿ˜!K–2.5 in tabStopsšœ Ÿ˜)K–2.5 in tabStopsšœ Ÿ"˜,K–2.5 in tabStopsšœ˜—K™—šœ™K™Kšœ'™'˜š Οnœžœžœžœ žœ˜CKšœ‘™‘—K˜š œžœžœžœ˜4Kšœ«™«—K˜š œžœžœžœ˜IKšœœ™.K™N—K˜š  œžœžœ ˜-Kšœ™—K˜š  œžœžœ ˜.Kšœ)™)—K˜š  œžœžœžœ˜,Kšœ@™@—K™—Kšœ%™%˜š œžœžœžœ˜%Kšœ<™<—K˜š œžœžœžœ ˜)Kšœ"™"—K˜š  œžœžœžœ žœ˜+Kšœ'™'—K™š  œžœžœžœ˜Kš œžœbžœžœ+žœ™·—K™KšœO™OK˜š œžœ7žœžœžœžœžœ˜aKšœœ'™AKšœδžœ$™‹—K˜š  œžœžœžœžœ˜!Kšœ!œ'™IKšœžœDžœ™|—K˜š œžœ žœ˜Kšœ œ™@Kšœ œ™@Kšœ]™]—K˜š  œžœ žœ˜Kšœt™t—K™š  œžœ žœžœžœ˜)Kšœr™r—K˜š  œžœ žœžœžœ˜,KšœCžœ™c—K™—KšœN™N˜š  œžœžœ ˜/KšœœŸœ™.Kšœ,™,—K˜š  œžœ žœ˜KšœœŸ$œ™AKšœk™k—K˜š   œžœžœžœžœ˜?KšœœŸ$œ™AKšœx™x—K˜š œžœžœžœ˜'Kšœ%™%Kšœ$žœžœ™L—K˜š  œžœžœžœžœ˜,Kšœ*œN™y—K˜š  œžœžœžœžœ˜ Kšœ&™&Kšœ#™#—K˜š  œžœžœžœžœ˜$Kšœ&™&Kšœ"™"—K˜š  œžœžœžœ˜-Kšœ ™ —K˜š œžœžœžœ˜5Kšœœ1™K—K˜š œžœžœ˜)šœœ7™QKšœ™—Kš œ žœžœžœžœ™6—K˜š œžœžœ˜(Kšœœ.™HKš œ žœžœžœžœ™6—K˜š œžœžœžœ˜+Kšœœ™,—K˜š  œžœžœžœ˜-KšœœŸœ ™,—K˜š  œžœ žœžœžœžœ˜/Kšœ#œŸœ Ÿœ™R—K™š  œžœžœžœžœ˜$KšœœŸœ™1Kšœ«™«—K˜š  œžœžœ žœžœžœ˜0KšœœŸœ™'Kšœ?™?—K˜š œžœžœžœžœžœžœ˜5Kšœœ3™SKšœ žœ-™=Kšœ.™.—K˜š   œžœžœžœžœ˜(Kšœ$™$Kšœ› œ3™Ο—K˜š œžœ Ÿ#œžœ ˜VKšœœWŸœ™‚—K˜š œžœžœžœ˜+KšœœŸœ™2—K˜š  œžœžœžœ˜.KšœœŸœ ™.—K˜š  œžœžœžœžœ˜%Kšœœ ™,—K˜š  œžœžœžœžœ˜%Kšœœ ™,—K˜š  œžœžœžœžœ˜$KšœœWŸœ™ˆ—K˜š  œžœžœžœ˜,KšœœŸœ™9—K˜š   œžœžœžœžœ˜)KšœœŸœ™'Kšœž™"—K˜š  œžœžœžœžœ˜5Kšœ™—K˜š  œžœžœžœžœ žœžœžœžœžœ˜cKšœl™l—K˜š œžœ Ÿžœ˜)Kšœ!™!—K˜š  œžœžœ˜-Kšœ/™/—K˜š  œžœžœ˜,Kšœ!™!—K˜š  œžœžœžœžœ˜8KšœœŸœ™%KšœK™K—K˜š œžœžœžœ˜&KšœœŸœ™8—K˜š œžœžœžœ˜%KšœœŸœ™8—K˜š  œžœžœŸžœžœ˜!KšœœŸœ™>Kšœ™K™—š  œžœžœŸžœžœ˜!KšœœŸœ™>Kšœ™—K˜š œžœžœžœ˜)KšœœŸ œ™'—K˜š  œžœžœžœžœ˜7KšœœŸ œ™'Kšœ!™!—K˜š   œžœžœŸžœžœ˜)KšœœŸ œ™,Kšœv™v—K˜—šœ!™!K˜š  œžœžœžœžœ˜#KšœœŸ œ™-Kšœ?žœ™X—K˜š   œžœžœžœžœ˜+KšœœŸ œ™-Kšœ6žœ™P—K˜š  œžœžœžœžœ˜3KšœœŸ œ™-Kšœ4™4—K˜š  œžœžœžœžœ˜1KšœœŸ œ™-Kšœ2™2—K˜š   œžœžŸœžœžŸ œ˜AKšœœŸ œ™-Kšœl™l—K˜š  œžœžŸœžœžŸœ˜GKšœœŸ œ™-Kšœl™l—K˜š  œžœžœžœžœ˜&KšœœŸ œ™-Kšœ žœ žœy™”—K˜š   œžœžœžœžœ˜*KšœœŸ œ™-Kšœ6žœ™Q—K˜š   œžœžœžœžœ˜)KšœœŸ œ ™8Kšœ2™2K˜—š  œžœžœžœžœ˜$KšœœŸ œ™.Kšœ=™=—K˜——Kšžœ˜K˜—…—4J