
    <<SymbolOps.mesa>>
        <<Copyright  1985 by Xerox Corporation.  All rights reserved.>>
        <<Satterthwaite, June 18, 1986 10:12:35 am PDT>>
        <<Rovner, July 6, 1983 1:36 pm>>
    <<Russ Atkinson (RRA) January 31, 1985 1:07:20 pm PST>>
        <<Sweet June 4, 1986 10:11:29 am PDT>>

    DIRECTORY
        Alloc: TYPE USING [Handle],
        BcdDefs: TYPE USING [Link, VersionStamp],
        ConvertUnsafe: TYPE USING [SubString],
        Symbols: TYPE,
        Target: TYPE MachineParms USING [PackedBitCount, packedFieldSize],
        Tree: TYPE USING [Index, Info, Link, Map];

    SymbolOps: DEFINITIONS = {
        OPEN Symbols;

    <<from/to UNSPEC and Tree.Info>>
        <<>>
        DecodeBitAddr: PROC[ba: UNSPEC] RETURNS[BitAddress] = INLINE {
            RETURN[LOOPHOLE[ba, BitAddress]]};
        DecodeBti: PROC[bti: UNSPEC] RETURNS[CBTIndex] = INLINE {
            RETURN[LOOPHOLE[bti, CBTIndex]]};
        DecodeCard: PROC[n: UNSPEC] RETURNS[CARD] = INLINE {RETURN[LOOPHOLE[n, CARD]]};
        DecodeLink: PROC[l: UNSPEC] RETURNS[BcdDefs.Link] = INLINE {
            RETURN[LOOPHOLE[l, BcdDefs.Link]]};
        DecodeTreeIndex: PROC[node: UNSPEC] RETURNS[Tree.Index] = INLINE {
            RETURN[LOOPHOLE[node, Tree.Index]]};
        DecodeType: PROC[t: UNSPEC] RETURNS[Type] = INLINE {RETURN[LOOPHOLE[t, Type]]};
        <<>>
        EncodeBitAddr: PROC[ba: BitAddress] RETURNS[UNSPEC] = INLINE {
            RETURN[LOOPHOLE[ba, UNSPEC]]};
        EncodeBti: PROC[bti: CBTIndex] RETURNS[UNSPEC] = INLINE {
            RETURN[LOOPHOLE[bti, UNSPEC]]};
        EncodeCard: PROC[n: CARD] RETURNS[UNSPEC] = INLINE {RETURN[LOOPHOLE[n, UNSPEC]]};
        EncodeLink: PROC[l: BcdDefs.Link] RETURNS[UNSPEC] = INLINE {
            RETURN[LOOPHOLE[l, UNSPEC]]};
        EncodeTreeIndex: PROC[node: Tree.Index] RETURNS[UNSPEC] = INLINE {
            RETURN[LOOPHOLE[node, UNSPEC]]};
        EncodeType: PROC[t: Type] RETURNS[UNSPEC] = INLINE {RETURN[LOOPHOLE[t, UNSPEC]]};
        <<>>
        ToBti: PROC[bti: Tree.Info] RETURNS[BTIndex] = INLINE {
            RETURN[LOOPHOLE[bti, BTIndex]]};
        ToCtx: PROC[ctx: Tree.Info] RETURNS[CTXIndex] = INLINE {
            RETURN[LOOPHOLE[ctx, CTXIndex]]};
        ToType: PROC[type: Tree.Info] RETURNS[Type] = INLINE {
            RETURN[LOOPHOLE[type, Type]]};

        FromBti: PROC[bti: BTIndex] RETURNS[Tree.Info] = INLINE {
            RETURN[LOOPHOLE[bti, Tree.Info]]};
        FromCtx: PROC[ctx: CTXIndex] RETURNS[Tree.Info] = INLINE {
            RETURN[LOOPHOLE[ctx, Tree.Info]]};
        FromType: PROC[type: Type] RETURNS[Tree.Info] = INLINE {
            RETURN[LOOPHOLE[type, Tree.Info]]};
        <<>>
        <<>>
    <<implemented by SymbolPack>>

        <<hash manipulation>>
            FindString: PROC[ConvertUnsafe.SubString] RETURNS[Name];
            HashValue: PROC[ConvertUnsafe.SubString] RETURNS[HVIndex];
            SubStringForName: PROC[Name] RETURNS[ConvertUnsafe.SubString];

        <<context management>>
            CtxEntries: PROC[CTXIndex] RETURNS[CARDINAL];
            FirstCtxSe: PROC[CTXIndex] RETURNS[ISEIndex];
            NextSe: PROC[ISEIndex] RETURNS[ISEIndex];
            SearchContext: PROC[name: Name, ctx: CTXIndex] RETURNS[ISEIndex];
            SeiForValue: PROC[value: Symbols.UNSPEC, ctx: CTXIndex] RETURNS[ISEIndex];

        <<module management>>
            FindMdi: PROC[BcdDefs.VersionStamp] RETURNS[MDIndex];

        <<type manipulation>>
            ArgCtx: PROC[CSEIndex] RETURNS[CTXIndex];
            ArgRecord: PROC[CSEIndex] RETURNS[RecordSEIndex];
            ClusterSe: PROC[Type] RETURNS[Type];
            EqTypes: PROC[Type, Type] RETURNS[BOOL];
            NormalType: PROC[Type] RETURNS[CSEIndex];
            RecordLink: PROC[RecordSEIndex] RETURNS[RecordSEIndex];
            RecordRoot: PROC[RecordSEIndex] RETURNS[RecordSEIndex];
            ReferentType: PROC[Type] RETURNS[Type];
            TransferTypes: PROC[Type] RETURNS[typeIn, typeOut: RecordSEIndex];
            TypeForm: PROC[Type] RETURNS[TypeClass];
            TypeLink: PROC[Type] RETURNS[Type];
            TypeRoot: PROC[Type] RETURNS[Type];
            UnderType: PROC[Type] RETURNS[CSEIndex];
            XferMode: PROC[Type] RETURNS[TransferMode];

        <<information returning procedures>>
            AUsForType: PROC[Type] RETURNS[CARD];
            BitsForRange: PROC[CARD] RETURNS[CARD];
            BitsForType: PROC[Type] RETURNS[BitCount];
            BitsPerElement: PROC[type: Type, packed: BOOL] RETURNS[BitCount];
            Cardinality: PROC[Type] RETURNS[CARD];
            FindExtension: PROC[sei: ISEIndex] RETURNS[type: ExtensionType, tree: Tree.Link];
            FnField: PROC[ISEIndex] RETURNS[offset: BitAddress, size: BitCount];
            LinkMode: PROC[sei: ISEIndex] RETURNS[Linkage];
            NameForSe: PROC[ISEIndex] RETURNS[Name];
            PackedSize: ARRAY Target.PackedBitCount OF NAT = Target.packedFieldSize;
            RecField: PROC[ISEIndex] RETURNS[offset: BitAddress, size: BitCount];
            RCType: PROC[Type] RETURNS[RefClass];
            VariantField: PROC[CSEIndex] RETURNS[ISEIndex];

        <<body table management>>
            EnumerateBodies: PROC[root: BTIndex, proc: PROC[BTIndex] RETURNS[stop: BOOL]]
                RETURNS[BTIndex];
            ParentBti: PROC[BTIndex] RETURNS[BTIndex];
            SiblingBti: PROC[BTIndex] RETURNS[BTIndex];
            SonBti: PROC[BTIndex] RETURNS[BTIndex];


    <<implemented by SymbolPackExt (extensions for building tables)>>

        Initialize: PROC[Alloc.Handle, UNCOUNTED ZONE];
        Reset, Finalize: PROC; 

        <<hash manipulation>>
            EnterString: PROC[ConvertUnsafe.SubString] RETURNS[Name];
            HashBlock: PROC RETURNS[LONG POINTER TO HashVector];

        <<context management>>
            NextLevel: PROC[ContextLevel] RETURNS[ContextLevel];
            CtxLevel: PROC[CTXIndex] RETURNS[ContextLevel];
            SetCtxLevel: PROC[CTXIndex, ContextLevel];
            BlockLevel: PROC[ContextLevel] RETURNS[ContextLevel];
            NewCtx: PROC[ContextLevel] RETURNS[CTXIndex];
            SetMainCtx: PROC[CTXIndex];
            ResetCtxList: PROC[CTXIndex];
            FirstVisibleSe: PROC[CTXIndex] RETURNS[ISEIndex];
            NextVisibleSe: PROC[ISEIndex] RETURNS[ISEIndex];
            VisibleCtxEntries: PROC[CTXIndex] RETURNS[CARDINAL];
            CtxVariant: PROC[CTXIndex] RETURNS[ISEIndex];

            StaticNestError: SIGNAL;

            MakeCtxSe: PROC[name: Name, ctx: CTXIndex] RETURNS[ISEIndex];
            MakeNonCtxSe: PROC[CARDINAL] RETURNS[CSEIndex];

            MakeSeChain: PROC[CTXIndex, CARDINAL, BOOL] RETURNS[ISEIndex];
            FillCtxSe: PROC[ISEIndex, Name, BOOL];
            NameClash: SIGNAL [name: Name];
            EnterExtension: PROC[sei: ISEIndex, type: ExtensionType, tree: Tree.Link];
            SetSeLink: PROC[sei, next: ISEIndex];

        <<body table utilities>>
            LinkBti: PROC[bti, parent: BTIndex];
            DelinkBti: PROC[BTIndex];

        <<copying within current table>>
            CopyArgSe: PROC[copy, master: ISEIndex];
            CopyBasicType: PROC[CSEIndex] RETURNS[CSEIndex];
            CopyXferType: PROC[CSEIndex, Tree.Map] RETURNS[CSEIndex];

        <<attribute extraction>>
            ConstantId: PROC[ISEIndex] RETURNS[BOOL];

        }.

