Author: coke
Date: Fri Sep 21 22:05:32 2007
New Revision: 21478

Modified:
   trunk/languages/tcl/src/grammar/expr/operators.pir

Log:
[tcl]

[expr -"2"] now returns {-2} instead of the incorrect {-2.0}



Modified: trunk/languages/tcl/src/grammar/expr/operators.pir
==============================================================================
--- trunk/languages/tcl/src/grammar/expr/operators.pir  (original)
+++ trunk/languages/tcl/src/grammar/expr/operators.pir  Fri Sep 21 22:05:32 2007
@@ -38,20 +38,28 @@
 .end
 
 # unary minus
+# XXX This breaks on -"2"; returns -2.0
 .sub 'prefix:-' :multi(String)
     .param pmc a
 
-    .local pmc __number
-    __number = get_root_global ['_tcl'], '__number'
+    .local pmc __number, __integer
+    __number  = get_root_global ['_tcl'], '__number'
 
     push_eh is_string
       a = __number(a)
     clear_eh
+    $S0 = typeof a
+    if $S0 == "TclInt" goto is_int
 
     $N0 = a
     $N0 = neg $N0
     .return($N0)
 
+is_int:
+    $I0 = a
+    $I0 = neg $I0
+    .return($I0)
+
 is_string:
     if a == '' goto empty_string
     tcl_error "can't use non-numeric string as operand of \"-\""

Reply via email to