perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r31865 - trunk/languages/pipp/src/common

Subject: [svn:parrot] r31865 - trunk/languages/pipp/src/common
From:
Date: Fri, 10 Oct 2008 13:00:05 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: bernhard
Date: Fri Oct 10 13:00:04 2008
New Revision: 31865

Modified:
   trunk/languages/pipp/src/common/builtins.pir
   trunk/languages/pipp/src/common/php_math.pir

Log:
[Pipp] Get rid of some 'to_number' method calls,
pass all but one test.


Modified: trunk/languages/pipp/src/common/builtins.pir
==============================================================================
--- trunk/languages/pipp/src/common/builtins.pir        (original)
+++ trunk/languages/pipp/src/common/builtins.pir        Fri Oct 10 13:00:04 2008
@@ -66,12 +66,12 @@
 
 
 ## symbolic unary
-.sub 'prefix:-'
-    .param pmc a
-    $P1 = a.'to_number'()
-    neg $P1
+.sub 'prefix:-' :multi(_)
+    .param num a
 
-    .return ($P1)
+    neg a
+
+    .return (a)
 .end
 
 .sub 'prefix:+'
@@ -101,22 +101,22 @@
 
 
 ## multiplicative
-.sub 'infix:*'
-    .param pmc a
-    .param pmc b
-    $P1 = a.'to_number'()
-    $P2 = b.'to_number'()
-    $P0 = mul $P1, $P2
-    .return ($P0)
+.sub 'infix:*' :multi(_,_)
+    .param num a
+    .param num b
+
+    $N0 = mul a, b
+
+    .return ($N0)
 .end
 
-.sub 'infix:/'
-    .param pmc a
-    .param pmc b
-    $P1 = a.'to_number'()
-    $P2 = b.'to_number'()
-    $P0 = div $P1, $P2
-    .return ($P0)
+.sub 'infix:/' :multi(_,_)
+    .param num a
+    .param num b
+
+    $N0 = div a, b
+
+    .return ($N0)
 .end
 
 .sub 'infix:%'
@@ -159,21 +159,17 @@
 
 ## additive
 .sub 'infix:+'
-    .param pmc a
-    .param pmc b
-    $P1 = a.'to_number'()
-    $P2 = b.'to_number'()
-    $P0 = add $P1, $P2
-    .return ($P0)
+    .param num a
+    .param num b
+    $N0 = add a, b
+    .return ($N0)
 .end
 
 .sub 'infix:-'
-    .param pmc a
-    .param pmc b
-    $P1 = a.'to_number'()
-    $P2 = b.'to_number'()
-    $P0 = sub $P1, $P2
-    .return ($P0)
+    .param num a
+    .param num b
+    $N0 = sub a, b
+    .return ($N0)
 .end
 
 .sub 'infix:.'

Modified: trunk/languages/pipp/src/common/php_math.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_math.pir        (original)
+++ trunk/languages/pipp/src/common/php_math.pir        Fri Oct 10 13:00:04 2008
@@ -80,7 +80,6 @@
     .RETURN_NULL()
   L1:
     $P1 = shift args
-    $P1 = $P1.'to_number'()
     $I0 = isa $P1, 'PhpFloat'
     unless $I0 goto L2
     $N1 = $P1
@@ -93,7 +92,13 @@
     $I0 = abs $I1
     .RETURN_LONG($I0)
   L3:
+    $I0 = isa $P1, 'array'
+    unless $I0 goto L4
     .RETURN_FALSE()
+  L4:
+    $N1 = $P1
+    $N0 = abs $N1
+    .RETURN_DOUBLE($N0)
 .end
 
 =item C<float acos(float number)>
@@ -641,7 +646,6 @@
     dec_point = '.'
     unless argc == 1 goto L1
     $P1 = shift args
-    $P1 = $P1.'to_number'()
     $N1 = $P1
     .return _number_format($N1, 0, dec_point, thousand_sep)
   L1:

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r31865 - trunk/languages/pipp/src/common, bernhard <=