TJaMIOImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Maureen Stone, February 14, 1985 6:42:18 pm PST
Doug Wyatt, March 23, 1985 4:15:21 pm PST
DIRECTORY
FS USING [Error, StreamOpen],
TJaM USING [AtomFromRope, Error, ExecuteStream, Frame, PopRope, PushRope, RegisterPrimitive, ROPE, STREAM];
TJaMIOImpl: CEDAR PROGRAM
IMPORTS FS, TJaM
~ BEGIN OPEN TJaM;
badName: ATOM ~ AtomFromRope[".badname"];
fsError: ATOM ~ AtomFromRope[".fserror"];
ApplyRun: PROC[frame: Frame] = {
fileName: ROPE ~ PopRope[frame];
errorAtom: ATOMNIL;
stream: STREAMNIL;
stream ← FS.StreamOpen[fileName !
FS.Error => {
SELECT error.code FROM
$unknownFile, $illegalName, $patternNotAllowed => errorAtom ← badName;
ENDCASE => { PushRope[frame, error.explanation]; errorAtom ← fsError };
CONTINUE;
};
];
IF stream#NIL THEN ExecuteStream[frame, stream]
ELSE ERROR Error[errorAtom];
};
RegisterPrimitive[".run", ApplyRun];
RegisterPrimitive[".stream", ApplyStream];
RegisterPrimitive[".readitem", ApplyReadItem];
RegisterPrimitive[".writeitem", ApplyWriteItem];
RegisterPrimitive[".writebytes", ApplyWriteBytes];
RegisterPrimitive[".killstream", ApplyKillStream];
RegisterPrimitive[".print", ApplyPrint];
RegisterPrimitive[".loadbcd", ApplyLoadBCD];
RegisterPrimitive[".iochar", ApplyIOChar];
RegisterPrimitive[".iobool", ApplyIOBool];
RegisterPrimitive[".ioint", ApplyIOInt];
RegisterPrimitive[".ioreal", ApplyIOReal];
RegisterPrimitive[".ioline", ApplyIOLine];
RegisterPrimitive[".iotoken", ApplyIOToken];
RegisterPrimitive[".iocedartoken", ApplyIOCedarToken];
RegisterPrimitive[".ioclose", ApplyIOClose];
END.