RopePrivate.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Paul Rovner, August 8, 1983 11:38 am
Russ Atkinson, January 29, 1985 10:22:16 am PST
Doug Wyatt, February 26, 1985 3:28:49 pm PST
DIRECTORY
PrincOps USING [zBNDCK, zDADD, zLI0, zLI1, zLINI, zPOP, zWSTRL],
Rope USING [ExtendPositive, ROPE, RopeRep, Text];
RopePrivate: CEDAR DEFINITIONS
IMPORTS Rope
SHARES Rope
= BEGIN OPEN PrincOps;
ROPE: TYPE ~ Rope.ROPE;
RopeRep: TYPE ~ Rope.RopeRep;
Text: TYPE ~ Rope.Text;
FirstPtr: TYPE = LONG POINTER TO INTEGER;
Ttext: TYPE = text RopeRep;
Tsubstr: TYPE = substr node RopeRep;
Tconcat: TYPE = concat node RopeRep;
Treplace: TYPE = replace node RopeRep;
Tobject: TYPE = object node RopeRep;
MaxDepth: CARDINAL = 32;
BoundsFault: PROC
= TRUSTED MACHINE CODE {zLI1; zLI0; zBNDCK;};
NonNeg: PROC [x: INT] RETURNS [INT]
= TRUSTED MACHINE CODE {zLINI; zBNDCK;};
Short: PROC [x: INT] RETURNS [CARDINAL]
= TRUSTED MACHINE CODE {zLI1; zBNDCK; zPOP; zLINI; zBNDCK;};
CheckLongAdd: PROC [x,y: INT] RETURNS [INT]
= TRUSTED MACHINE CODE {zDADD; zLINI; zBNDCK;};
SingleSize: PROC [base: ROPE] RETURNS [INT,Text]
= TRUSTED INLINE {
IF base = NIL THEN RETURN [0, NIL];
{ first: INTEGERLOOPHOLE[base, FirstPtr]^;
IF first >= 0 THEN RETURN [Rope.ExtendPositive[first], LOOPHOLE[base]] };
RETURN [LOOPHOLE[base, REF Tobject].size, NIL];
};
DoubleSize: PROC [r1,r2: ROPE] RETURNS [s1: INT, s2: INT, both: BOOL]
= TRUSTED INLINE {
t1,t2: Text;
[s1,t1] ← SingleSize[r1];
[s2,t2] ← SingleSize[r2];
both ← t1 # NIL AND t2 # NIL;
};
InlineDepth: PROC [r: ROPE] RETURNS [INTEGER]
= TRUSTED INLINE {
IF r = NIL THEN RETURN[0];
WITH r: r SELECT FROM
node => WITH x: r SELECT FROM
substr => RETURN [x.depth];
concat => RETURN [x.depth];
replace => RETURN [x.depth];
ENDCASE;
ENDCASE;
RETURN[1];
};
QStore: UNSAFE PROC [c: CHAR, base: Text, index: CARDINAL]
= UNCHECKED MACHINE CODE {zWSTRL, 4;};
quick store into string for hack purposes, no NIL or bounds check
END.