5 .param pmc argv :slurpy
9 unless argc goto bad_args
11 .local string subcommand_name
12 subcommand_name = shift argv
15 options = get_root_global ['_tcl'; 'helpers'; 'info'], 'options'
17 .local pmc select_option
18 select_option = get_root_global ['_tcl'], 'select_option'
20 .local string canonical_subcommand
21 canonical_subcommand = select_option(options, subcommand_name)
23 .local pmc subcommand_proc
26 subcommand_proc = get_root_global ['_tcl';'helpers';'info'], canonical_subcommand
27 if null subcommand_proc goto bad_subcommand
29 .return subcommand_proc(argv)
32 .return ('') # once all commands are implemented, remove this...
35 die 'wrong # args: should be "info subcommand ?argument ...?"'
39 .namespace [ 'helpers'; 'info' ]
46 if argc != 1 goto bad_args
50 .local string procname
53 .local pmc splitNamespace
54 splitNamespace = get_root_global ['_tcl'], 'splitNamespace'
58 ns = splitNamespace(procname)
63 $P1 = get_root_global ns, name
64 if null $P1 goto no_args
66 $P2 = getattribute $P1, 'args'
67 if null $P2 goto no_args
75 $S0 .= "\" isn't a procedure"
79 die 'wrong # args: should be "info args procname"'
87 if argc != 1 goto bad_args
89 .local string procname
92 .local pmc splitNamespace
93 splitNamespace = get_root_global ['_tcl'], 'splitNamespace'
97 ns = splitNamespace(procname)
102 $P1 = get_root_global ns, name
103 if null $P1 goto no_body
104 $P2 = getattribute $P1, 'HLL_source'
105 if null $P2 goto no_body
111 $S0 .= "\" isn't a procedure"
115 die 'wrong # args: should be "info body procname"'
122 if argc != 1 goto bad_args
127 $P1 = compileTcl(body)
132 get_results '0,0', $P0, $S0
133 if $S0 == 'missing close-brace' goto fail
134 if $S0 == 'missing close-bracket' goto fail
135 if $S0 == 'missing "' goto fail
142 die 'wrong # args: should be "info complete command"'
150 if argc != 3 goto bad_args
154 .local string procname, argname, varname
160 setVar = get_root_global ['_tcl'], 'setVar'
162 .local pmc splitNamespace
163 splitNamespace = get_root_global ['_tcl'], 'splitNamespace'
167 ns = splitNamespace(procname)
172 $P1 = get_root_global ns, name
173 if null $P1 goto not_proc
175 $P2 = getattribute $P1, 'defaults'
176 $P9 = getattribute $P1, 'args'
177 if null $P2 goto check_arg
180 if_null $P3, check_arg
189 # there's no default. is there even an arg?
191 $P4 = new 'Iterator', $P3
193 unless $P4 goto not_argument
195 if $S1==argname goto no_default
201 $S0 .= "\" doesn't have an argument \""
213 $S0 = "couldn't store default value in variable \""
221 $S0 .= "\" isn't a procedure"
226 die 'wrong # args: should be "info default procname arg varname"'
235 if argc > 1 goto bad_args
237 .local pmc mathfunc,iterator,retval
239 mathfunc = get_root_namespace ['tcl'; 'tcl'; 'mathfunc']
240 iterator = new 'Iterator', mathfunc
242 retval = new 'TclList'
244 .local pmc globber,rule,match
245 globber = compreg 'Tcl::Glob'
246 if argc == 1 goto got_glob
253 rule = globber.'compile'($S1)
255 unless iterator goto end
259 unless match goto loop
267 die 'wrong # args: should be "info functions ?pattern?"'
275 if argc > 1 goto bad_args
278 if argc ==0 goto done_setup
280 $P1 = compreg 'Tcl::Glob'
281 .local string pattern
284 # cheat and just remove a leading "::" for now
285 $S0 = substr pattern, 0, 2
286 if $S0 != "::" goto create_glob
287 $S0 = substr pattern, 0, 2, ''
290 matching = $P1.'compile'(pattern)
294 result = new 'TclList'
297 ns = get_root_global 'tcl'
300 iter = new 'Iterator', ns
302 unless iter goto iter_loop_end
304 $S2 = substr $S1, 0, 1
305 unless $S2 == '&' goto iter_loop
307 if_null matching, add_result
309 unless $P2 goto iter_loop
318 die 'wrong # args: should be "info commands ?pattern?"'
327 if argc != 1 goto bad_args
329 .local string varname
332 .local pmc readVar, found_var
333 readVar = get_root_global ['_tcl'], 'readVar'
335 found_var = readVar(varname)
343 die 'wrong # args: should be "info exists varName"'
352 if argc != 0 goto bad_args
354 $P1 = get_root_global ['tcl'], '$tcl_version'
358 die 'wrong # args: should be "info tclversion"'
368 if argc != 0 goto bad_args
370 $P1 = get_root_global ['tcl'], '$tcl_patchLevel'
374 die 'wrong # args: should be "info patchlevel"'
384 if argc != 0 goto bad_args
386 $P1 = get_root_global ['tcl'], '$tcl_library'
390 die 'wrong # args: should be "info library"'
400 if argc == 0 goto iterate
401 if argc > 1 goto bad_args
404 .local pmc call_chain, lexpad
405 call_chain = get_root_global ['_tcl'], 'call_chain'
406 $I1 = elements call_chain
407 if $I1 == 0 goto get_globals
409 lexpad = call_chain[-1]
411 .local pmc iter, retval
413 iter = new 'Iterator', lexpad
414 retval = new 'TclList'
418 $S0 = substr elem, 0, 1, ''
419 unless $S0 == '$' goto loop
426 die 'wrong # args: should be "info vars ?pattern?"'
429 .return 'globals'(argv)
438 if argc == 0 goto current_level
439 if argc == 1 goto find_level
441 die 'wrong # args: should be "info level ?number?"'
444 .local pmc call_chain
445 call_chain = get_root_global ['_tcl'], 'call_chain'
446 $I0 = elements call_chain
450 .local pmc toInteger, getCallLevel
451 toInteger = get_root_global ['_tcl'], 'toInteger'
452 getCallLevel = get_root_global ['_tcl'], 'getCallLevel'
456 level = toInteger(level)
457 if level >= 0 goto find_info_level
458 level = getCallLevel(level)
462 .local pmc info_level
463 info_level = get_root_global ['_tcl'], 'info_level'
464 $P0 = info_level[level]
473 if argc > 1 goto bad_args
475 .local pmc ns,iterator,retval
477 ns = get_root_namespace ['tcl']
478 iterator = new 'Iterator', ns
480 retval = new 'TclList'
482 .local pmc globber,rule,match
483 globber = compreg 'Tcl::Glob'
484 if argc == 1 goto got_glob
491 rule = globber.'compile'($S1)
493 unless iterator goto end
497 unless match goto loop
505 die 'wrong # args: should be "info globals ?pattern?"'
515 # sharedlibextension - should be able to pull this from parrot config.
516 .sub 'sharedlibextension'
522 .sub 'nameofexecutable'
526 if argc goto bad_args
527 $P1 = get_root_global ['_tcl'], 'nameofexecutable'
530 die 'wrong # args: should be "info nameofexecutable"'
545 .sub 'anon' :anon :load
547 options = new 'TclList'
550 push options, 'cmdcount'
551 push options, 'commands'
552 push options, 'complete'
553 push options, 'default'
554 push options, 'exists'
555 push options, 'frame'
556 push options, 'functions'
557 push options, 'globals'
558 push options, 'hostname'
559 push options, 'level'
560 push options, 'library'
561 push options, 'loaded'
562 push options, 'locals'
563 push options, 'nameofexecutable'
564 push options, 'patchlevel'
565 push options, 'procs'
566 push options, 'script'
567 push options, 'sharedlibextension'
568 push options, 'tclversion'
571 set_root_global ['_tcl'; 'helpers'; 'info'], 'options', options
578 # vim: expandtab shiftwidth=4 ft=pir: