SiroccoDupOps.Mesa
Copyright Ó 1986, 1987 by Xerox Corporation. All rights reserved.
Bill Jackson (bj) July 28, 1987 2:28:40 am PDT
DIRECTORY
Convert USING [ CardFromRope, RopeFromRope ],
Rope USING [ ROPE ],
SiroccoATDef USING [ ConstantNode ],
SiroccoBaseDef USING [ ],
SiroccoCGDef USING [ Generic, idNode, decimalNode, hexNode, octalNode, ropeNode ],
SiroccoPrivate USING [ CComponent, CComponentBody, CType, CTypeBody, FunctionList, TABLES ],
SymTab USING [ Key ];
SiroccoDupOps: CEDAR PROGRAM
IMPORTS Convert
EXPORTS SiroccoBaseDef ~ {
OPEN SiroccoBaseDef, SiroccoCGDef, SiroccoPrivate;
ROPE: TYPE ~ Rope.ROPE;
Since Casaba only understands INTs
card: PUBLIC PROC [in: INT] RETURNS [out: CARD] ~ { out ← CARD[in] };
int: PUBLIC PROC [in: CARD] RETURNS [out: INT] ~ { out ← INT[in] };
nat: PUBLIC PROC [in: INT] RETURNS [out: NAT] ~ { out ← NAT[in] };
values from tokens
TextFromID: PUBLIC PROC [id: idNode] RETURNS [text: ROPE] ~ { text ← id.text };
CardFromDecimal: PUBLIC PROC [decimal: decimalNode] RETURNS [card: CARD] ~ {
card ← Convert.CardFromRope[decimal.text] };
CardFromHex: PUBLIC PROC [hex: hexNode] RETURNS [card: CARD] ~ {
card ← Convert.CardFromRope[hex.text, 16] };
CardFromOctal: PUBLIC PROC [octal: octalNode] RETURNS [card: CARD] ~ {
card ← Convert.CardFromRope[octal.text, 8] };
GetRopeFromRope: PUBLIC PROC [rope: ropeNode] RETURNS [r: ROPE] ~ {
r ← Convert.RopeFromRope[rope.text, TRUE] }; -- FALSE?
values / constant fcns
False: PUBLIC PROC [ ] RETURNS [false: BOOL] ~ { false ← FALSE };
True: PUBLIC PROC [ ] RETURNS [true: BOOL] ~ { true ← TRUE };
Arithmetic Operations
AddOne: PUBLIC PROC [in: INT] RETURNS [out: INT] ~ { out ← in.SUCC };
Add: PUBLIC PROC [a, b: INT] RETURNS [c: INT] ~ { c ← (a + b) };
Subtract: PUBLIC PROC [a: INT, b: INT] RETURNS [c: INT] ~ { c ← (a - b) };
Convince Casaba that things are undamaged
Copy: PUBLIC PROC [t1: ROPE, t2: CType, t3: SiroccoATDef.ConstantNode, t4: TABLES]
RETURNS
[ROPE, CType, SiroccoATDef.ConstantNode, TABLES] ~ {
RETURN
[t1, t2, t3, t4] };
CopyAll: PUBLIC PROC [in1: ROPE, in2: FunctionList, in3: TABLES]
RETURNS
[out1: ROPE, out2: FunctionList, out3: TABLES] ~ {
out1 ← in1; out2 ← in2; out3 ← in3; };
CopyCComponent: PUBLIC PROC [in: CComponent] RETURNS [out: CComponent] ~ {
out ← in };
CopyFunctionList: PUBLIC PROC [in: FunctionList] RETURNS [out: FunctionList] ~ {
out ← in };
CopyRope: PUBLIC PROC [in: ROPE] RETURNS [out: ROPE] ~ { out ← in };
CopyTables: PUBLIC PROC [t1: TABLES] RETURNS [t2: TABLES] ~ { t2 ← t1 };
Hash Keys
CreateKey: PUBLIC PROC [id: idNode] RETURNS [key: ROPE] ~ { key ← id.text };
RopeFromKey: PUBLIC PROC [key: SymTab.Key] RETURNS [rope: ROPE] ~ { rope ← key };
Predicates
NotEnumeration: PUBLIC PROC[type: CType] RETURNS [result: BOOLEAN] ~ { result ← NOT ( type.class = enum ) };
Record Constructors
MkCComponent: PUBLIC PROC [name: ROPE, valBinding: INT, typeBinding: ROPE, sibling: CComponent] RETURNS [new: CComponent] ~ { new ← NEW[CComponentBody ← [name: name, sibling: sibling, type: typeBinding, val: valBinding]] };
MkCType: PUBLIC PROC [class: SiroccoCGDef.Generic, bound: INT, children: CComponent] RETURNS [new: CType] ~ { new ← NEW[CTypeBody ← [bound: bound, children: children, class: class]] };
MkNILCComponent: PUBLIC PROC RETURNS [nil: CComponent] ~ { nil ← NIL };
}.