Author: coke
Date: Sat Jan 14 09:59:53 2006
New Revision: 11184

Added:
   trunk/languages/tcl/lib/builtins/while.tmt
Removed:
   trunk/languages/tcl/lib/builtins/while.pir
Modified:
   trunk/MANIFEST
   trunk/languages/tcl/config/root.in
   trunk/languages/tcl/tools/gen_inline.pl
Log:
tcl -

o Convert [while] from a hand-rolled builtin to a templated, inline builtin.



Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Sat Jan 14 09:59:53 2006
@@ -1255,7 +1255,7 @@ languages/tcl/lib/builtins/return.pir   
 languages/tcl/lib/builtins/time.tmt               [tcl]
 languages/tcl/lib/builtins/trace.pir              [tcl]
 languages/tcl/lib/builtins/variable.pir           [tcl]
-languages/tcl/lib/builtins/while.pir              [tcl]
+languages/tcl/lib/builtins/while.tmt              [tcl]
 languages/tcl/lib/commands/after.pir              [tcl]
 languages/tcl/lib/commands/append.pir             [tcl]
 languages/tcl/lib/commands/array.pir              [tcl]

Modified: trunk/languages/tcl/config/root.in
==============================================================================
--- trunk/languages/tcl/config/root.in  (original)
+++ trunk/languages/tcl/config/root.in  Sat Jan 14 09:59:53 2006
@@ -26,7 +26,8 @@ GENERATED_INLINES = \
  $(BUILTIN)@[EMAIL PROTECTED] \
  $(BUILTIN)@[EMAIL PROTECTED] \
  $(BUILTIN)@[EMAIL PROTECTED] \
- $(BUILTIN)@[EMAIL PROTECTED]
+ $(BUILTIN)@[EMAIL PROTECTED] \
+ $(BUILTIN)@[EMAIL PROTECTED]
 
 DEPS = \
 [EMAIL PROTECTED]@[EMAIL PROTECTED]@after.pir \
@@ -88,7 +89,6 @@ [EMAIL PROTECTED]@[EMAIL PROTECTED]@unset.pir \
 [EMAIL PROTECTED]@[EMAIL PROTECTED]@uplevel.pir \
 [EMAIL PROTECTED]@[EMAIL PROTECTED]@upvar.pir \
 [EMAIL PROTECTED]@[EMAIL PROTECTED]@variable.pir \
[EMAIL PROTECTED]@[EMAIL PROTECTED]@while.pir \
 [EMAIL PROTECTED]@compiler.pir \
 [EMAIL PROTECTED]@conversions.pir \
 [EMAIL PROTECTED]@expression.pir \

Added: trunk/languages/tcl/lib/builtins/while.tmt
==============================================================================
--- (empty file)
+++ trunk/languages/tcl/lib/builtins/while.tmt  Sat Jan 14 09:59:53 2006
@@ -0,0 +1,16 @@
+{
+  command => 'while',
+  usage=> "test:expr command:script",
+  code => <<'END_PIR'
+
+while_loop_{register_command}:
+{register_test_code}
+$I{register_test} = $P{register_test}
+unless $I{register_test} goto while_loop_done_{register_command}
+{register_command_code}
+goto while_loop_{register_command}
+
+while_loop_done_{register_command}:
+
+END_PIR
+}

Modified: trunk/languages/tcl/tools/gen_inline.pl
==============================================================================
--- trunk/languages/tcl/tools/gen_inline.pl     (original)
+++ trunk/languages/tcl/tools/gen_inline.pl     Sat Jan 14 09:59:53 2006
@@ -20,10 +20,10 @@ actual compiler for that command.
 Many builtins need to use the same type of code, and do the same kind
 of optimizations. By making the inline'd versions more declarative, this
 lets us do this work B<once> instead of many times, which B<should> make it
-easier to inline more builtins accurately.j
+easier to inline more builtins accurately.
 
-Currently support options with no arguments, and the following types of
-arguments: variable name, integer, channel, list, and string.
+Currently supports the following types of arguments: 
+variable name, integer, channel, list, string, script, and expressions.
 
 =cut
 
@@ -136,6 +136,8 @@ END_PIR
 add_wrapped(<<END_PIR);
   .local pmc __script_compile
   __script_compile = find_global '_Tcl', 'compile'
+  .local pmc __expression_compile
+  __expression_compile = find_global '_Tcl', '__expression_compile'
 END_PIR
 
 # Now, grab each arg off the list and compile it, handling defaults, etc.
@@ -164,6 +166,15 @@ foreach my $arg (@args_opts) {
 END_PIR
             },
         },
+        expr => {
+            pre => sub {
+                add_wrapped(<<END_PIR);
+  .local string ${arg_register}_code
+  ($arg_register,${arg_register}_code) = __expression_compile(register_num, 
$argument)
+  register_num = $arg_register + 100
+END_PIR
+            },
+        },
         var => {
             pre => sub {
 
@@ -396,7 +407,7 @@ sub parse_usage {
       (\w+)     # name
       (?:
         :       # literal :
-        (int | string | var | list | channel | script)
+        (int | string | var | list | channel | script | expr)
       )?
       (?:
         =

Reply via email to