5 .param pmc argv :slurpy
10 .local pmc compileExpr
11 compileExpr = get_root_global ['_tcl'], 'compileExpr'
13 if argc == 0 goto no_args
17 ns = $P0['namespace'; 1]
19 # we have to do arg checking first, to make sure we got the proper type of
20 # exception. but [expr] checking has to happen before that. so replace each
21 # string expression with a Sub that represents it. and while we're at it,
22 # strip out the "then"s.
24 # convert to the expression to a Sub
26 $P0 = compileExpr($S0, 'ns'=>ns)
29 if $I0 == argc goto no_script
34 unless $S0 == 'then' goto arg_next
36 # we have to do this check first so that "then" shows up in the error
38 if $I0 == argc goto no_script
45 if $I0 == argc goto arg_end
48 if $S0 == 'elseif' goto arg_elseif
49 if $S0 == 'else' goto arg_else
57 if $I0 == argc goto no_expression
59 # convert to the expression to a Sub
61 $P0 = compileExpr($S0)
64 if $I0 == argc goto no_script
70 unless $S0 == 'then' goto arg_next
72 # we have to do this check first so that "then" shows up in the error
74 if $I0 == argc goto no_script
83 if $I0 == argc goto no_script
86 if $I0 != argc goto extra_words_after_else
89 # now we can do the actual evaluation
90 .local pmc compileTcl, toBoolean
91 compileTcl = get_root_global ['_tcl'], 'compileTcl'
92 toBoolean = get_root_global ['_tcl'], 'toBoolean'
104 $P0 = compileTcl(code, 'ns'=>ns)
109 if $I0 == argc goto nothing
112 if $S0 == 'elseif' goto elseif
113 if $S0 == 'else' goto else
129 $P0 = compileTcl(code, 'ns'=>ns)
132 extra_words_after_else:
133 die 'wrong # args: extra words after "else" clause in "if" command'
139 die 'wrong # args: no expression after "if" argument'
144 $S0 = 'wrong # args: no script following "' . $S0
145 $S0 = $S0 . '" argument'
151 $S0 = 'wrong # args: no expression after "' . $S0
152 $S0 = $S0 . '" argument'
160 # vim: expandtab shiftwidth=4 ft=pir: