forked from pmichaud/pmtcl
/
info.pm
210 lines (153 loc) · 4.39 KB
/
info.pm
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
our sub info(*@args) {
Info::dispatch_command(|@args);
}
module Info;
our %Arg_limits;
our %Info_funcs;
INIT {
%Info_funcs<args> := Info::args;
%Arg_limits<args> := [1, 1, 'procname'];
%Info_funcs<body> := Info::body;
%Arg_limits<body> := [1, 1, 'procname'];
%Info_funcs<cmdcount> := Info::cmdcount;
%Arg_limits<cmdcount> := [0, 0, ''];
%Info_funcs<commands> := Info::commands;
%Arg_limits<commands> := [0, 1, '?pattern?'];
%Info_funcs<complete> := Info::complete;
%Arg_limits<complete> := [1, 1, 'complete'];
%Info_funcs<default> := Info::default;
%Arg_limits<default> := [3, 3, 'procname arg varname'];
%Info_funcs<exists> := Info::exists;
%Arg_limits<exists> := [1, 1, 'varName'];
%Info_funcs<frame> := Info::frame;
%Arg_limits<frame> := [0, 1, '?number?'];
%Info_funcs<functions> := Info::functions;
%Arg_limits<functions> := [0, 1, '?pattern?'];
%Info_funcs<globals> := Info::globals;
%Arg_limits<globals> := [0, 1, '?pattern?'];
%Info_funcs<hostname> := Info::hostname;
%Arg_limits<hostname> := [0, 0, ''];
%Info_funcs<level> := Info::level;
%Arg_limits<level> := [0, 1, '?number?'];
%Info_funcs<library> := Info::library;
%Arg_limits<library> := [0, 0, ''];
%Info_funcs<loaded> := Info::loaded;
%Arg_limits<loaded> := [0, 1, '?interp?'];
%Info_funcs<locals> := Info::locals;
%Arg_limits<locals> := [0, 1, '?pattern?'];
%Info_funcs<nameofexecutable> := Info::nameofexecutable;
%Arg_limits<nameofexecutable> := [0, 0, ''];
%Info_funcs<patchlevel> := Info::patchlevel;
%Arg_limits<patchlevel> := [0, 0, ''];
%Info_funcs<procs> := Info::procs;
%Arg_limits<procs> := [0, 1, '?pattern?'];
%Info_funcs<script> := Info::script;
%Arg_limits<script> := [0, 1, '?filename?'];
%Info_funcs<sharedlibextension> := Info::sharedlibextension;
%Arg_limits<sharedlibextension> := [0, 0, ''];
%Info_funcs<tclversion> := Info::tclversion;
%Arg_limits<tclversion> := [0, 0, ''];
%Info_funcs<vars> := Info::vars;
%Arg_limits<vars> := [0, 1, '?pattern?'];
}
# Handle wrong # args, bad option errors.
# dispatch to internal NQP subs for actual work.
our sub dispatch_command(*@args) {
my $argc := +@args;
if $argc-- < 1 {
error('wrong # args: should be "info subcommand ?argument ...?"');
}
my @opts := <args body cmdcount commands complete default exists frame functions globals hostname level library loaded locals nameofexecutable patchlevel procs script sharedlibextension tclversion vars>;
my $cmd := _tcl::select_option(@opts, @args.shift, 'subcommand');
my @limits := %Arg_limits{$cmd};
if $argc > @limits[1] || $argc < @limits[0] {
my $msg := @limits[2];
$msg := ' ' ~ $msg if $msg ne '';
error("wrong # args: should be \"info $cmd$msg\"")
}
my &subcommand := %Info_funcs{$cmd};
&subcommand(|@args);
}
my sub args($procname) {
my $sub := pir::get_hll_global__PS($procname);
error("\"$procname\" isn't a procedure")
if pir::isnull($sub);
pir::getprop__PsP('args', $sub);
}
my sub body($procname) {
'';
}
my sub cmdcount() {
0;
}
my sub commands($pattern = '*') {
# XXX globbing
# XXX other NS.
my $globalNS := pir::get_root_global__PS('tcl');
try {
my $result := $globalNS{$pattern};
return $pattern;
CATCH {
return '';
}
}
}
my sub complete($command) {
0;
}
my sub default($procname, $arg, $varname) {
set($varname, ''); # XXX placeholder
0;
}
my sub exists($varname) {
0;
}
my sub frame($number?) {
0;
}
my sub functions($pattern = '*') {
'';
}
my sub globals($pattern = '*') {
'';
}
my sub hostname() {
'';
}
my sub level($number?) {
'';
}
my sub library() {
my %GLOBALS := pir::get_hll_global__ps('%GLOBALS');
%GLOBALS<tcl_library>;
}
my sub loaded($interp?) {
'';
}
my sub locals($pattern = '*') {
'';
}
my sub nameofexecutable() {
'';
}
my sub patchlevel() {
my %GLOBALS := pir::get_hll_global__ps('%GLOBALS');
%GLOBALS<tcl_patchLevel>;
}
my sub procs($pattern = '*') {
'';
}
my sub tclversion() {
my %GLOBALS := pir::get_hll_global__ps('%GLOBALS');
%GLOBALS<tcl_version>;
}
my sub script($filename?) {
'';
}
my sub sharedlibextension() {
'';
}
my sub vars($pattern = '*') {
'';
}
# vim: filetype=perl6: