home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / GhostScript / !GhostScr / 6_01 / lib / traceop.ps < prev    next >
Text File  |  2000-03-09  |  3KB  |  86 lines

  1. %    Copyright (C) 1992, 1993, 1994, 1999 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % $Id: traceop.ps,v 1.1 2000/03/09 08:40:40 lpd Exp $
  16. % Trace individual operators or procedures.
  17. % <opref> is <opname> or <opname> <dict>
  18. %    (dict defaults to dict where op is currently defined, if writable;
  19. %    otherwise uses userdict)
  20. % <opref> traceop prints vmem usage before;
  21. % <opref> <numargs|preproc> prints arguments or runs proc before;
  22. % <opref> <numargs|preproc> <numresults|postproc>
  23. %    also prints results or runs proc after.
  24. % If traceflush is true, flush the output after each printout.
  25. /traceflush true def
  26.  
  27. currentpacking true setpacking
  28. .currentglobal true .setglobal
  29.  
  30. % Define the default "before" action
  31. /tracebefore { vmstatus 3 traceprint pop pop pop } def
  32.  
  33. % Define the default "after" action
  34. /traceafter { } def
  35.  
  36. /traceprint {
  37.   dup type /integertype eq {
  38.     1 sub -1 0 { ( ) print index ==only } for
  39.   } {
  40.     exec
  41.   } ifelse
  42. } bind def
  43. /traceend {
  44.   traceflush { flush } if
  45. } bind def
  46. /traceop {
  47.   userdict begin
  48.   dup type dup /nametype eq exch /dicttype eq or { { tracebefore } } if
  49.   1 index type dup /nametype eq exch /dicttype eq or { { traceafter } } if
  50.   /.tpost exch def /.tpre exch def
  51.   dup type /dicttype ne {
  52.     dup where not { userdict 1 index {} put userdict } if
  53.   } if
  54.   dup dup wcheck not {
  55.     (Warning: substituting userdict for non-writable dictionary.) =
  56.     pop userdict
  57.   } if
  58.   /.tddict exch def   /.tdict exch def   /.tname exch cvlit def
  59.   .currentglobal [
  60.   .tname /=only cvx ( ) /print cvx
  61.     /.tpre load /traceprint cvx /traceend cvx
  62.     .tdict .tname get /.tdef 1 index cvlit def
  63.     dup xcheck {
  64.       dup type dup /arraytype eq exch /packedarraytype eq or {
  65.     /exec cvx
  66.       } if
  67.     } if
  68.     /.tpost load /traceprint cvx () /= cvx /traceend cvx
  69.   .tdef gcheck /.tpre load gcheck and /.tpost load gcheck and .setglobal
  70.   ] cvx
  71.   .tdef type /operatortype eq {
  72.     .tname exch .makeoperator
  73.   } if
  74.   exch .setglobal
  75.   .tddict exch .tname exch put
  76.   end        % userdict
  77. } bind def
  78. /tracebind /bind load def    % in case someone wants to put it back
  79. /bind { } def        % disable
  80.  
  81. .setglobal
  82. setpacking
  83.