tagged release 0.6.4
[parrot.git] / languages / tcl / runtime / builtin / inline.pir
blob3bbce5783cccd173f25fc13e3c8990e9ed163745
2 # [inline <language> { code }]
4 # a partcl only command that should probably live in a loadable lib.
6 # Like eval, except that you must specify a registered compiler.
8 .HLL 'Tcl', 'tcl_group'
9 .namespace []
11 .sub '&inline'
12   .param pmc argv :slurpy
14   .local int argc
15   argc = argv
17   if argc != 2 goto bad_args
19   .local string language,code
21   language = argv[0]
22   code     = argv[1]
24   $P1 = compreg language
25   if null $P1 goto fail
26   push_eh compiler_error
27     $P0 = $P1(code)
28   pop_eh
29   push_eh runtime_error
30     $P0()
31   pop_eh
32   .return ('')
35 # First pass at RT#40748
36 compiler_error:
37   get_results '0,0', $P1, $S1
38   $S1 = 'compile error: ' . $S1
39   tcl_error $S1
41 runtime_error:
42   get_results '0,0', $P1, $S1
43   $S1 = 'runtime error: ' . $S1
44   tcl_error $S1
46 bad_args:
47   tcl_error 'wrong # args: should be "inline language code"'
49 fail:
50   $S0 = 'invalid language "'
51   $S0 .= language
52   $S0 .= '" specified'
53   tcl_error $S0
54 .end
56 # Local Variables:
57 #   mode: pir
58 #   fill-column: 100
59 # End:
60 # vim: expandtab shiftwidth=4 ft=pir: