Start.ps
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Doug Wyatt, August 11, 1987 5:55:22 pm PDT
Starting an interpreter:
Run PSPackage.bcd
← &streams ← ViewerIO.CreateViewerStreams["PostScript"]
← PSLanguage1Impl.Create[&streams.in, &streams.out]
% systemdict definitions
systemdict begin
/=string 128 string def
/=print { dup type /stringtype ne { //=string cvs } if print } bind def
/= { //=print exec (\r) print } bind def
/stack { count dup 1 add copy //= repeat pop } bind def
/==print { 0 begin typeprint end } dup 0 24 dict put def
/== { //==print exec (\r) print } bind def
/==print load 0 get begin
/dictdict 10 dict def
dictdict begin
/systemdict dup load exch def
/userdict dup load exch def
/errordict dup load exch def
% /$error dup load exch def
% /statusdict dup load exch def
% /FontDirectory dup load exch def
% /execdict dup load exch def
% /serverdict dup load exch def
% /$printerdict dup load exch def
% /$idleTimeDict dup load exch def
end
/tprint /print load def
/cvsprint { =string cvs tprint ( ) tprint } def
/typeprint { dup type exec } def
/nulltype { pop (-null- ) tprint } def
/integertype { cvsprint } def
/realtype { cvsprint } def
/booleantype { cvsprint } def
/arraytype { dup rcheck
{ dup dup xcheck
{ ({ ) tprint { typeprint } forall (} ) tprint }
{ ([ ) tprint { typeprint } forall (] ) tprint }
ifelse wcheck not { (readonly ) print } if }
{ pop (-array- ) tprint }
ifelse } def
/packedarraytype { dup rcheck
{ dup dup xcheck
{ ({ ) tprint { typeprint } forall (} ) tprint }
{ ([ ) tprint { typeprint } forall (] ) tprint }
ifelse wcheck not { (readonly ) print } if }
{ pop (-packedarray- ) tprint }
ifelse } def
/stringtype { dup rcheck
{ dup (\() tprint tprint (\) ) tprint wcheck not { (readonly ) print } if }
{ pop (-string- ) tprint }
ifelse } def
/nametype { dup xcheck not { (/) tprint } if cvsprint } def
/dicttype { dup dictdict exch known
{ dictdict exch get cvsprint }
{ pop (-dict- ) tprint }
ifelse } def
/filetype { pop (-file- ) tprint } def
/operatortype { =string cvs tprint (^ ) tprint } def
/marktype { pop (-mark- ) tprint } def
/fonttype { pop (-fontid- ) tprint } def
/savetype { pop (-savelevel- ) tprint } def
end
/handleerror { errordict /handleerror get exec } bind def
/$error 13 dict def
$error /ostackarray null put
$error /initializing true put
/.error {
$error exch /errorname exch put
$error exch /command exch put
$error /newerror true put
$error /errorname get /VMerror ne {
$error /ostackarray get null eq {
% $error /estackarray 250 array put
$error /ostackarray 500 array put
$error /dstackarray 20 array put
} if
count $error /ostackarray get exch 0 exch getinterval astore
$error exch /ostack exch put
$error /dstack $error /dstackarray get dictstack put
% $error /estack $error /estackarray get execstack dup length 2 sub 0 exch getinterval put
$error /ostack get aload pop
} if
$error /initializing get { handleerror } if
stop
} bind def
/findfont {
dup FontDirectory exch known
{ FontDirectory exch get }
{ =print ( not found, using Courier.\n) print flush FontDirectory /Courier get }
ifelse
} bind def
/Run { dup == flush run } def
(StandardEncoding.ps) Run
% (FontDirectory.ps) Run
end
% systemdict readonly pop
% errordict definitions
errordict begin
/handleerror { $error begin newerror { /newerror false def
(%%[ Error: ) print errorname =print (; OffendingCommand: ) print
/command load =print ( ]%%) = flush } if end } bind def
/stackunderflow { /stackunderflow //.error //exec } def
/unregistered { /unregistered //.error //exec } def
/dictstackunderflow { /dictstackunderflow //.error //exec } def
/typecheck { /typecheck //.error //exec } def
/undefinedresult { /undefinedresult //.error //exec } def
/invalidexit { /invalidexit //.error //exec } def
/dictfull { /dictfull //.error //exec } def
/nocurrentpoint { /nocurrentpoint //.error //exec } def
/limitcheck { /limitcheck //.error //exec } def
/invalidaccess { /invalidaccess //.error //exec } def
/invalidfileaccess { /invalidfileaccess //.error //exec } def
/ioerror { /ioerror //.error //exec } def
/invalidfont { /invalidfont //.error //exec } def
/invalidrestore { /invalidrestore //.error //exec } def
/rangecheck { /rangecheck //.error //exec } def
/execstackoverflow { /execstackoverflow //.error //exec } def
/dictstackoverflow { /dictstackoverflow //.error //exec } def
/stackoverflow { /stackoverflow //.error //exec } def
/unmatchedmark { /unmatchedmark //.error //exec } def
/syntaxerror { /syntaxerror //.error //exec } def
/undefined { /undefined //.error //exec } def
/undefinedfilename { /undefinedfilename //.error //exec } def
/VMerror { /VMerror //.error //exec } def
/timeout { /timeout /timeout //.error //exec } def
/interrupt /stop load def
end
% userdict definitions
/cleardictstack { countdictstack 2 sub { end } repeat } bind def
/pstack { count dup 1 add copy { == } repeat pop } bind def
% executive
/execdict 6 dict def
/executive {
execdict begin
/execdepth execdepth 1 add def
(\nCedar PostScript(tm) Version ) print version print
(\nCopyright (c) 1985 Adobe Systems Incorporated.) print
(\nCopyright (c) 1987 Xerox Corporation.\n) print
{ % loop
/quitflag false def
$error /newerror false put
/prompt load stopped { handleerror (Error during prompt execution\n) print exit } if
{ mark /stmtfile (%statementedit) (r) file def } stopped
{ % if....
cleartomark $error /newerror get { % if
$error /errorname get /undefinedfilename ne { handleerror } if
$error /newerror false put exit } if
}
{ % ..else
pop stmtfile end { cvx exec } stopped execdict begin
{ handleerror stmtfile closefile } if
}
ifelse
} loop
/quitflag false def
/execdepth execdepth 1 sub def
end
$error /doclose false put
interrupt
} bind def
/start {
execdict /execdepth 0 put
$error /initializing false put
executive
} bind store
% /prompt { (PS) print execdepth { (>) print } repeat flush } bind def