DefineDragonImpl.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
last edited by E. McCreight, March 8, 1984 6:13:19 pm PST
DefineDragonImpl:
CEDAR
PROGRAM
IMPORTS AMBridge, AMMiniModel, AMTypes, Atom, Rope, RuntimeError =
BEGIN
DefineInterface:
PROC [ interfaceFileName: Rope.
ROPE, prop:
ATOM,
enumsToExpand:
LIST
OF
REF ←
NIL ] =
BEGIN
iType: AMTypes.Type = AMMiniModel.AcquireIRType[defsName: interfaceFileName];
nComponents: NAT = AMTypes.NComponents[iType];
FOR i:
NAT
IN [1..nComponents]
DO
BEGIN ENABLE RuntimeError.UNCAUGHT => LOOP;
value: Dragon.Word;
compType: AMTypes.Type = AMTypes.IndexToType[iType, i];
SELECT AMTypes.UnderClass[compType]
FROM
IN [cardinal..longInteger], enumerated, subrange =>
BEGIN
TRUSTED {value ← AMBridge.TVToLC[AMTypes.IndexToDefaultInitialValue[iType, i]]};
Atom.PutProp[atom: Atom.MakeAtom[AMTypes.IndexToName[iType, i]],
prop: prop, val: NEW[Dragon.Word ← value]];
END;
type =>
BEGIN
typeName: Rope.ROPE = AMTypes.IndexToName[iType, i];
FOR tName:
LIST
OF
REF ← enumsToExpand, tName.rest
WHILE tName#
NIL
DO
IF Rope.Equal[typeName,
NARROW[tName.first]]
THEN
BEGIN
enumType: AMTypes.Type = AMTypes.UnderType[AMTypes.TVToType[AMTypes.IndexToDefaultInitialValue[iType, i]]];
IF AMTypes.TypeClass[enumType]#enumerated THEN LOOP;
FOR tv: AMTypes.
TV ← AMTypes.First[enumType], AMTypes.Next[tv]
WHILE tv#
NIL
DO
TRUSTED {value ← AMBridge.TVToLC[tv]};
Atom.PutProp[atom: Atom.MakeAtom[AMTypes.TVToName[tv
! AMTypes.Error => IF reason=badIndex THEN CONTINUE ELSE REJECT]],
prop: prop, val: NEW[Dragon.Word ← value]];
ENDLOOP;
EXIT;
END;
ENDLOOP;
END;
ENDCASE => NULL;
END;
ENDLOOP;
END;
inst: Rope.ROPE = "Inst";
DefineInterface[interfaceFileName: "DragOpsCross.bcd", prop: $DragonValue,
enumsToExpand: LIST[inst]
! RuntimeError.UNCAUGHT => CONTINUE];
END.