1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
// $Id: Subject.pike,v 1.2 2002/10/21 02:10:54 grendel Exp $ 
 
//! This is a probe subject which you can send in somewhere to 
//! get probed (not to be confused with a probe object, which 
//! does some active probing). All calls to lfuns will be printed 
//! to stderr. It is possible to name a subject by passing one 
//! string as first and only argument when creating the subject 
//! object. 
//! 
//! @example 
//! > object s = Debug.Subject(); 
//! create got ({ }) 
//! > random(s); 
//! _random got ({ }) 
//! (1) Result: 0 
//! > abs(s); 
//! `< got ({ /* 1 element */ 
//!   0 
//! }) 
//!   _sprintf got ({ /* 2 elements */ 
//!   79, 
//!   ([ /* 1 element */ 
//!     "indent":2 
//!   ]) 
//! }) 
//! (2) Result: Debug.Subject 
//! > abs(class { inherit Debug.Subject; int `<(mixed ... args) { return 1; } }()); 
//! create got ({ }) 
//! `- got ({ }) 
//! destroy got ({ }) 
//! (3) Result: 0 
//! > pow(s,2); 
//! `[] got ({ /* 1 element */ 
//!   "pow" 
//! }) 
//! Attempt to call the NULL-value 
//! Unknown program: 0(2) 
//! HilfeInput:1: ___HilfeWrapper() 
 
#define PROXY(X,Y) X(mixed ... args) { werror(id+#X+" got %O\n", args); return Y; } 
 
static string id = ""; 
 
void create(mixed ... args) { 
  werror("create got %O\n", args); 
  if(sizeof(args)==1 && stringp(args[0])) 
    id = "(" + args[0] + ") "; 
} 
 
void PROXY(destroy, 0); 
 
mixed PROXY(`->, 0); 
mixed PROXY(`->=, 0); 
mixed PROXY(`[], 0); 
mixed PROXY(`[]=, 0); 
 
mixed PROXY(`+, 0); 
mixed PROXY(`-, 0); 
mixed PROXY(`&, 0); 
mixed PROXY(`|, 0); 
mixed PROXY(`^, 0); 
mixed PROXY(`<<, 0); 
mixed PROXY(`>>, 0); 
mixed PROXY(`*, 0); 
mixed PROXY(`/, 0); 
mixed PROXY(`%, 0); 
mixed PROXY(`~, 0); 
 
int(0..1) PROXY(`==, 0); 
int(0..1) PROXY(`<, 0); 
int(0..1) PROXY(`>, 0); 
int PROXY(`!, 0); 
 
int PROXY(__hash, 0); 
int PROXY(_sizeof, 0); 
mixed PROXY(cast, 0); 
mixed PROXY(`(), 0); 
 
mixed PROXY(``+, 0); 
mixed PROXY(``-, 0); 
mixed PROXY(``&, 0); 
mixed PROXY(``|, 0); 
mixed PROXY(``^, 0); 
mixed PROXY(``<<, 0); 
mixed PROXY(``>>, 0); 
mixed PROXY(``*, 0); 
mixed PROXY(``/, 0); 
mixed PROXY(``%, 0); 
 
mixed PROXY(`+=, 0); 
 
int(0..1) PROXY(_is_type, 0); 
int PROXY(_equal, 0); 
mixed PROXY(_m_delete, 0); 
 
array _indices(mixed ... args) {  
   werror(id+"_values got %O\n", args);  
   return ::_indices();  
} 
 
array _values(mixed ... args) {  
   werror(id+"_values got %O\n", args);  
   return ::_values();  
} 
 
object _get_iterator(mixed ... args) { 
  werror(id+"_get_iterator got %O\n", args); 
  string iid = id==""?"":id[1..sizeof(id)-3]; 
  return this_program("("+iid+" iterator) "); 
} 
 
string _sprintf(mixed ... args) { 
  werror(id+"_sprintf got %O\n", args); 
  return sprintf("Debug.Subject"+id); 
} 
 
mixed PROXY(_random, 0);