GIF89a; EcchiShell v1.0
//proc/self/root/usr/share/ghostscript/ % Copy a dictionary to the current (local) VM, % and make it read-only if its current definition is. dup maxlength dict .copydict 1 index load wcheck not { readonly } if } .bind def % When this is called, the dictionary stack is in its initial state, % and there is (anomalously) only one gstate on the gstate stack. /.initlocaldicts { % - .initlocaldicts - -2 vmreclaim .currentglobal //systemdict begin //false .setglobal % Since localdicts doesn't exist yet, references from % systemdict to local objects won't get restored if % a context switch happens in this code. Therefore, % until localdicts is defined, we have to keep all our % state on the operand stack. % Acquire userdict. %****** WRONG IF NON-STANDARD INITIAL DSTACK ****** countdictstack array dictstack { dup gcheck not { exit } if pop } forall % Create localdicts with a local copy of each dictionary, % except for userdict and userparams, which just need % to be filled in. mark savedlocaldicts { 1 index /userdict eq { % Stack: userdict mark ... /userdict inituserdict counttomark 1 add index .copydict } { 1 index /userparams eq { % Stack: userdict mark ... /userparams inituserparams userparams .copydict } { .copylocal } ifelse } ifelse } forall /internaldict dup .makeinternaldict .makeoperator .dicttomark readonly /localdicts exch put % localdicts is now defined in userdict. % Copy the definitions into systemdict. localdicts { .forcedef } executeonly forall % Set the user parameters. userparams readonly .setuserparams % Establish the initial gstate(s). /savedinitialgstate .systemvar setgstate gsave % Wrap up. end .setglobal } bind executeonly odef % Check whether an object is a procedure. /.proccheck { % .proccheck dup xcheck exch type dup /arraytype eq exch /packedarraytype eq or and } bind def % Create a context with private local VM. % The .localfork operator does all the work, but we must ensure that % .initlocaldicts gets called when the new context starts up. /localfork { % ... % % localfork .currentglobal //true .setglobal 3 index dup .proccheck not { pop .setglobal /localfork .systemvar /typecheck signalerror } if {exec .initlocaldicts} aload pop 3 1 roll 3 packedarray cvx 4 1 roll 5 -1 roll pop .setglobal .localfork } odef % Fork a context that shares VM. The .fork operator creates an empty % userparams dictionary for the context, but we still need to initialize % this dictionary when the new context starts up. /.postfork { % - .postfork - % Initialize the user parameters. savedlocaldicts /userparams get userparams .copydict readonly pop } odef /fork { % ... fork .currentglobal //false .setglobal 1 index dup .proccheck not { pop .setglobal /fork .systemvar /typecheck signalerror } if {exec .postfork} aload pop 3 1 roll 3 packedarray cvx 3 1 roll exch pop .setglobal .fork } odef % ------ Halftone phase ------ % /sethalftonephase { % sethalftonephase - -1 2 index 2 index .setscreenphase pop pop } odef /currenthalftonephase { % - currenthalftonephase 0 .currentscreenphase } odef % ------ Device-source images ------ */ .imagetypes 2 /.image2 load put % ------ Device information ------ % /.deviceinfodict mark /Colors //null /GrayValues //null /RedValues //null /GreenValues //null /BlueValues //null /ColorValues //null .dicttomark readonly def /deviceinfo { % - deviceinfo currentdevice //.deviceinfodict .getdeviceparams .dicttomark dup begin /ColorValues .knownget { 0 le { currentdict /ColorValues undef } { % hack around devices that incorrect set GrayValues Colors 3 eq { 1 } { GrayValues } ifelse RedValues mul GreenValues mul BlueValues mul ColorValues ne { currentdict /GrayValues undef currentdict /RedValues undef currentdict /GreenValues undef currentdict /BlueValues undef } if } ifelse } if currentdict end readonly } odef % The current implementation allocates a 2-element array each time. % Perhaps we should change this to 2 separate parameters for X and Y? /.wtdict mark /wtranslation //null .dicttomark readonly def /wtranslation { % - wtranslation currentdevice //.wtdict .getdeviceparams exch pop exch pop aload pop } odef currentdict /.wtdict .undef % ------ View clipping ------ % /rectviewclip { % rectviewclip - % rectviewclip - newpath .rectappend viewclip } odef