RopeEditingBLTImpl.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by Bill Paxton, March 1981
Paxton, 10-Feb-82 9:13:35
Maxwell, January 5, 1983 12:11 pm
Russ Atkinson, July 22, 1983 5:55 pm
Doug Wyatt, January 18, 1984 12:03:37 pm PST
Michael Plass, February 18, 1985 11:29:01 am PST
DIRECTORY
PrincOpsUtils USING [ByteBlt],
Rope USING [TextRep],
RopeEditingBLT USING [];
RopeEditingBLTImpl: CEDAR PROGRAM
IMPORTS PrincOpsUtils
EXPORTS RopeEditingBLT
SHARES Rope
= BEGIN
TextRep: TYPE = Rope.TextRep;
minBlt: NAT ~ 16;
TextPointer: PROC[ref: REF READONLY TextRep]
RETURNS[LONG POINTER] = TRUSTED INLINE {
RETURN[LOOPHOLE[ref, LONG POINTER]+SIZE[TextRep[0]]];
};
StringPointer: PROC[ref: REF READONLY TEXT]
RETURNS[LONG POINTER] = TRUSTED INLINE {
RETURN[LOOPHOLE[ref, LONG POINTER]+SIZE[TEXT[0]]];
};
ByteBltBlock: TYPE = MACHINE DEPENDENT RECORD [
blockPointer: LONG POINTER,
startIndex, stopIndexPlusOne: CARDINAL
];
TextToTextBlt: PUBLIC PROC [
from: REF READONLY TextRep, fromLoc: NAT,
to: REF TextRep, toLoc: NAT,
nChars: NAT] = {
nBlt: NAT ~ (IF nChars>minBlt THEN nChars-1 ELSE 0);
IF nChars=0 THEN RETURN;
FOR i: NAT IN[nBlt..nChars) DO to[toLoc+i] ← from[fromLoc+i] ENDLOOP;
always transfer the last byte with an assignment, to get the bounds check
IF nBlt#0 THEN TRUSTED { [] ← PrincOpsUtils.ByteBlt[
to: [blockPointer: TextPointer[to],
startIndex: toLoc, stopIndexPlusOne: toLoc+nBlt],
from: [blockPointer: TextPointer[from],
startIndex: fromLoc, stopIndexPlusOne: fromLoc+nBlt]
] };
};
TextToStringBlt: PUBLIC PROC [
from: REF READONLY TextRep, fromLoc: NAT,
to: REF TEXT, toLoc: NAT,
nChars: NAT] = {
nBlt: NAT ~ (IF nChars>minBlt THEN nChars-1 ELSE 0);
IF nChars=0 THEN RETURN;
FOR i: NAT IN[nBlt..nChars) DO to[toLoc+i] ← from[fromLoc+i] ENDLOOP;
always transfer the last byte with an assignment, to get the bounds check
IF nBlt#0 THEN TRUSTED { [] ← PrincOpsUtils.ByteBlt[
to: [blockPointer: StringPointer[to],
startIndex: toLoc, stopIndexPlusOne: toLoc+nBlt],
from: [blockPointer: TextPointer[from],
startIndex: fromLoc, stopIndexPlusOne: fromLoc+nBlt]
] };
};
StringToTextBlt: PUBLIC PROC [
from: REF READONLY TEXT, fromLoc: NAT,
to: REF TextRep, toLoc: NAT,
nChars: NAT] = {
nBlt: NAT ~ (IF nChars>minBlt THEN nChars-1 ELSE 0);
IF nChars=0 THEN RETURN;
FOR i: NAT IN[nBlt..nChars) DO to[toLoc+i] ← from[fromLoc+i] ENDLOOP;
always transfer the last byte with an assignment, to get the bounds check
IF nBlt#0 THEN TRUSTED { [] ← PrincOpsUtils.ByteBlt[
to: [blockPointer: TextPointer[to],
startIndex: toLoc, stopIndexPlusOne: toLoc+nBlt],
from: [blockPointer: StringPointer[from],
startIndex: fromLoc, stopIndexPlusOne: fromLoc+nBlt]
] };
};
StringToStringBlt: PUBLIC PROC [
from: REF READONLY TEXT, fromLoc: NAT,
to: REF TEXT, toLoc: NAT,
nChars: NAT] = {
nBlt: NAT ~ (IF nChars>minBlt THEN nChars-1 ELSE 0);
IF nChars=0 THEN RETURN;
FOR i: NAT IN[nBlt..nChars) DO to[toLoc+i] ← from[fromLoc+i] ENDLOOP;
always transfer the last byte with an assignment, to get the bounds check
IF nBlt#0 THEN TRUSTED { [] ← PrincOpsUtils.ByteBlt[
to: [blockPointer: StringPointer[to],
startIndex: toLoc, stopIndexPlusOne: toLoc+nBlt],
from: [blockPointer: StringPointer[from],
startIndex: fromLoc, stopIndexPlusOne: fromLoc+nBlt]
] };
};
END.