summaryrefslogtreecommitdiff
path: root/ipl/procs/iftrace.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/procs/iftrace.icn')
-rw-r--r--ipl/procs/iftrace.icn71
1 files changed, 71 insertions, 0 deletions
diff --git a/ipl/procs/iftrace.icn b/ipl/procs/iftrace.icn
new file mode 100644
index 0000000..1b12623
--- /dev/null
+++ b/ipl/procs/iftrace.icn
@@ -0,0 +1,71 @@
+############################################################################
+#
+# File: iftrace.icn
+#
+# Subject: Procedures to trace Icon function calls
+#
+# Author: Stephen B. Wampler
+#
+# Date: July 14, 1997
+#
+############################################################################
+#
+# This file is in the public domain.
+#
+############################################################################
+#
+# Contributor: Ralph E. Griswold
+#
+############################################################################
+#
+# These procedures provide tracing for Icon functions by using procedure
+# wrappers to call the functions.
+#
+# iftrace(fncs[]) sets tracing for a list of function names.
+#
+############################################################################
+#
+# Note: The functions that can be traced and their procedure wrappers should
+# be organized and coordinated to assure consistency and to allow for
+# extended function repertoire.
+#
+############################################################################
+#
+# Links: ifncs
+#
+############################################################################
+
+invocable all
+
+link ifncs
+
+procedure iftrace(args[]) #: trace built-in functions
+ local nextarg, arg
+
+ every set_trace(!args)
+
+ return
+end
+
+procedure set_trace(vf)
+ local vp
+ static traceset, case1, case2
+
+ initial {
+ traceset := set()
+ every insert(traceset, function())
+ case1 := &lcase || &ucase
+ case2 := &ucase || &lcase
+ }
+
+ if member(traceset,vf) then {
+ &trace := -1 # have to also trace all procedures!
+ vp := vf
+ # reverse case of first letter
+ vp[1] := map(vp[1], case1, case2)
+ variable(vp) :=: variable(vf)
+ return
+ }
+ else fail
+
+end