C2CCodeUtils.mesa
Copyright Ó 1987, 1988, 1989, 1990, 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, 1987
Christian Jacobi, January 26, 1990 11:19:42 am PST
DIRECTORY
C2CDefs,
Rope;
C2CCodeUtils: CEDAR DEFINITIONS =
BEGIN
Code: TYPE = C2CDefs.Code;
ROPE: TYPE = Rope.ROPE;
CodeOrRope: TYPE = REF;
CString: PROC [r: ROPE] RETURNS [ROPE];
--given an arbitray rope returns a legal string in C (within "'s)
RopeFromInt: PROC [i: INT] RETURNS [ROPE];
--plain conversion, but better caching
ConstC: PROC [c: CARD] RETURNS [Code];
--returns code representing a constant
ConstI: PROC [c: INT] RETURNS [Code];
--returns code representing a constant
Mask: PROC [i: INT] RETURNS [mask: ROPE];
--returns an octal mask (C) with i rightmost bits set; i<=bitsPerWord!
ComplexMask: PUBLIC PROC [ones, zeroes: INT] RETURNS [mask: ROPE];
--returns an octal mask for (2**ones-1) * 2**zeroes
ConstMul: PROC [code: Code, factor: CARD] RETURNS [Code];
--returns code multiplied by a constant
ConstDiv: PROC [code: Code, divisor: CARD] RETURNS [Code];
--returns code divided by a constant
ConstMod: PROC [code: Code, divisor: CARD] RETURNS [Code];
--returns remainder of code divided by a constant
MaskOut: PROC [code: Code, bits: INT] RETURNS [Code];
--returns code ← code & Mask[bits]
MaskNShift: PROC [word: Code, bits: INT, start: INT, wsz: INT] RETURNS [Code];
--masks bits bits of c starting with start
--no word boundary crossings!
--wsz: unit size of word [word, halfword, byte]
END.