]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/traceop.ps
merge
[plan9front.git] / sys / lib / ghostscript / traceop.ps
1 %    Copyright (C) 1992, 1993, 1994, 1999 Aladdin Enterprises.  All rights reserved.
2
3 % This software is provided AS-IS with no warranty, either express or
4 % implied.
5
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
9
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
16 % $Id: traceop.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
17 % Trace individual operators or procedures.
18 % <opref> is <opname> or <opname> <dict>
19 %    (dict defaults to dict where op is currently defined, if writable;
20 %    otherwise uses userdict)
21 % <opref> traceop prints vmem usage before;
22 % <opref> <numargs|preproc> prints arguments or runs proc before;
23 % <opref> <numargs|preproc> <numresults|postproc>
24 %    also prints results or runs proc after.
25 % If traceflush is true, flush the output after each printout.
26 /traceflush true def
27
28 currentpacking true setpacking
29 .currentglobal true .setglobal
30
31 % Define the default "before" action
32 /tracebefore { vmstatus 3 traceprint pop pop pop } def
33
34 % Define the default "after" action
35 /traceafter { } def
36
37 /traceprint {
38   dup type /integertype eq {
39     1 sub -1 0 { ( ) print index ==only } for
40   } {
41     exec
42   } ifelse
43 } bind def
44 /traceend {
45   traceflush { flush } if
46 } bind def
47 /traceop {
48   userdict begin
49   dup type dup /nametype eq exch /dicttype eq or { { tracebefore } } if
50   1 index type dup /nametype eq exch /dicttype eq or { { traceafter } } if
51   /.tpost exch def /.tpre exch def
52   dup type /dicttype ne {
53     dup where not { userdict 1 index {} put userdict } if
54   } if
55   dup dup wcheck not {
56     (Warning: substituting userdict for non-writable dictionary.) =
57     pop userdict
58   } if
59   /.tddict exch def   /.tdict exch def   /.tname exch cvlit def
60   .currentglobal [
61   .tname /=only cvx ( ) /print cvx
62     /.tpre load /traceprint cvx /traceend cvx
63     .tdict .tname get /.tdef 1 index cvlit def
64     dup xcheck {
65       dup type dup /arraytype eq exch /packedarraytype eq or {
66         /exec cvx
67       } if
68     } if
69     /.tpost load /traceprint cvx () /= cvx /traceend cvx
70   .tdef gcheck /.tpre load gcheck and /.tpost load gcheck and .setglobal
71   ] cvx
72   .tdef type /operatortype eq {
73     .tname exch .makeoperator
74   } if
75   exch .setglobal
76   .tddict exch .tname exch put
77   end           % userdict
78 } bind def
79 /tracebind /bind load def       % in case someone wants to put it back
80 /bind { } def           % disable
81
82 .setglobal
83 setpacking