4 .HLL 'Tcl', 'tcl_group'
8 .param pmc argv :slurpy
12 if argc != 2 goto bad_args
14 .local string oldName, newName
19 $P0 = get_root_global ['_tcl'], 'epoch'
22 .local pmc sub, args, builtin, ns
25 ns = $P1['namespace'; 1]
29 if null sub goto doesnt_exist
31 # if the newName is '', just delete the sub
32 .local int delete_only
34 if newName != '' goto delete_sub
40 if delete_only goto delete_builtin
45 # first check to make sure it doesn't already exist
47 if null $P0 goto set_new_sub
49 $S0 = "can't rename to \""
51 $S0 .= '": command already exists'
58 builtin = get_root_global ['_tcl'; 'builtins'], oldName
59 if null builtin goto return
61 $P0 = get_root_namespace ['_tcl'; 'builtins']
64 if delete_only goto return
67 set_root_global ['_tcl'; 'builtins'], newName, builtin
73 if newName == '' goto cant_delete
75 $S0 = "can't rename \""
77 $S0 .= "\": command doesn't exist"
81 $S0 = "can't delete \""
83 $S0 .= "\": command doesn't exist"
87 tcl_error 'wrong # args: should be "rename oldName newName"'
94 # vim: expandtab shiftwidth=4 ft=pir: