Author: fperrad
Date: Tue Feb 28 00:02:51 2006
New Revision: 11770

Modified:
   trunk/languages/lua/Lua/pir.pm
   trunk/languages/lua/lib/luabasic.pir
   trunk/languages/lua/lib/luamath.pir
   trunk/languages/lua/lib/luapir.pir
   trunk/languages/lua/lib/luastring.pir
   trunk/languages/lua/lib/luatable.pir
   trunk/languages/lua/pmc/luanumber.pmc

Log:
Lua :
- use inc opcode

Modified: trunk/languages/lua/Lua/pir.pm
==============================================================================
--- trunk/languages/lua/Lua/pir.pm      (original)
+++ trunk/languages/lua/Lua/pir.pm      Tue Feb 28 00:02:51 2006
@@ -79,7 +79,7 @@
        my $self = shift;

        my ($op) = @_;

        my $FH = $self->{fh};

-       print $FH "  add $op->{result}->{symbol}, 1.0\n";

+       print $FH "  inc $op->{result}->{symbol}\n";

 }

 

 sub visitFindGlobalOp {


Modified: trunk/languages/lua/lib/luabasic.pir
==============================================================================
--- trunk/languages/lua/lib/luabasic.pir        (original)
+++ trunk/languages/lua/lib/luabasic.pir        Tue Feb 28 00:02:51 2006
@@ -357,10 +357,12 @@
     zero = 0.0
     .return (ipairs, t, zero)
 L0:
-    .local pmc n
+    $N0 = checknumber(i)
+    inc $N0
     .local pmc ret
+    .local pmc n
     new n, .LuaNumber
-    n = i + 1.0
+    n = $N0
     ret = t[n]
     unless ret goto L1
     .return (n, ret)
@@ -545,7 +547,7 @@
     $P0 = argv[i]
     $P1 = $P0."tostring"()
     print $P1
-    i = i + 1
+    inc i
     goto L1
 L3:
     print "\n"
@@ -813,8 +815,8 @@
     unless i < n goto L1
     $P0 = list[index]
     ret[i] = $P0
-    index = index + 1.0
-    i = i + 1
+    inc index
+    inc i
     goto L0
 L1:
     .return (ret :flat)

Modified: trunk/languages/lua/lib/luamath.pir
==============================================================================
--- trunk/languages/lua/lib/luamath.pir (original)
+++ trunk/languages/lua/lib/luamath.pir Tue Feb 28 00:02:51 2006
@@ -335,7 +335,7 @@
     if dmax > d goto L2
     dmax = d
 L2:
-    i = i + 1
+    inc i
     goto L1
 L3:
     new ret, .LuaNumber
@@ -365,7 +365,7 @@
     if dmin < d goto L2
     dmin = d
 L2:
-    i = i + 1
+    inc i
     goto L1
 L3:
     new ret, .LuaNumber

Modified: trunk/languages/lua/lib/luapir.pir
==============================================================================
--- trunk/languages/lua/lib/luapir.pir  (original)
+++ trunk/languages/lua/lib/luapir.pir  Tue Feb 28 00:02:51 2006
@@ -168,8 +168,8 @@
 L1:
     $P0 = table[$P1]
     unless $P0 goto L2
-    add $I1, 1
-    add $P1, 1.0
+    inc $I1
+    inc $P1
     goto L1
 L2:
     .return ($I1)
@@ -198,7 +198,7 @@
 L1:
     if i >= argc goto L2
     curr = argv[i]
-    i = i + 1
+    inc i
     key = i
     ret[key] = curr
     goto L1
@@ -221,7 +221,7 @@
     new index, .LuaNumber
     index = 0.0
 L1:
-    add index, 1.0
+    inc index
     value = table[index]
     unless value goto L2
     .return (index, value)    
@@ -318,8 +318,8 @@
     if i >= argc goto L2
     $P0 = argv[i]
     table[index] = $P0
-    add index, 1.0
-    i = i + 1
+    inc index
+    inc i
     goto L1
 L2:
     .return (table)

Modified: trunk/languages/lua/lib/luastring.pir
==============================================================================
--- trunk/languages/lua/lib/luastring.pir       (original)
+++ trunk/languages/lua/lib/luastring.pir       Tue Feb 28 00:02:51 2006
@@ -112,7 +112,7 @@
     .param int len
     if pos >= 0 goto L0
     pos = len + pos
-    pos = pos + 1
+    inc pos
 L0:
     .return (pos)
 .end
@@ -138,7 +138,7 @@
     $I1 = posrelat($I1, $I0)
     if $I1 == 0 goto L0
     if $I1 > $I0 goto L0
-    $I1 = $I1 - 1
+    dec $I1
     $I2 = ord $S0, $I1
     new ret, .LuaNumber
     ret = $I2
@@ -176,7 +176,7 @@
     c = checknumber(curr)
     s = chr c
     b = concat b, s
-    i = i + 1
+    inc i
     goto L1
 L2:
     new ret, .LuaString
@@ -314,7 +314,7 @@
     $I2 = $I0
 L1:
     unless $I1 <= $I2 goto L2
-    $I1 = $I1 - 1
+    dec $I1
     $S1 = substr $S0, $I1, $I2
     goto L3
 L2:

Modified: trunk/languages/lua/lib/luatable.pir
==============================================================================
--- trunk/languages/lua/lib/luatable.pir        (original)
+++ trunk/languages/lua/lib/luatable.pir        Tue Feb 28 00:02:51 2006
@@ -315,7 +315,7 @@
     .local int pos
     checktype(table, "table")
     n = getn(table)
-    n = n + 1
+    inc n
     unless_null arg3, L1
     pos = n
     value = arg2
@@ -330,7 +330,7 @@
     setn(table, n)
     new index, .LuaNumber
 L4:
-    n = n - 1
+    dec n
     unless n >= pos goto L5
     index = n
     $P0 = table[index]

Modified: trunk/languages/lua/pmc/luanumber.pmc
==============================================================================
--- trunk/languages/lua/pmc/luanumber.pmc       (original)
+++ trunk/languages/lua/pmc/luanumber.pmc       Tue Feb 28 00:02:51 2006
@@ -69,6 +69,19 @@
 

 /*

 

+=item C<void init()>

+

+Initializes the number to zero.

+

+=cut

+

+*/

+    void init() {

+        PMC_num_val(SELF) = 0.0;

+    }

+

+/*

+

 =item C<PMC* new_from_string(STRING *rep, INTVAL flags)>

 

 Return a LuaNumber PMC created from a string (Implementation

@@ -184,6 +197,32 @@
 

 /*

 

+=item C<void increment()>

+

+Increments the number.

+

+=cut

+

+*/

+    void increment () {

+        PMC_num_val(SELF) ++;

+    }

+

+/*

+

+=item C<void decrement()>

+

+Decrements the number.

+

+=cut

+

+*/

+    void decrement () {

+        PMC_num_val(SELF) --;

+    }

+

+/*

+

 =item C<PMC* neg (PMC * dest)>

 

 =cut

@@ -296,19 +335,6 @@
         }

     }

 

-    PMC* add_float (FLOATVAL value, PMC* dest) {

-        if (!dest)

-            dest = pmc_new(INTERP, SELF->vtable->base_type);

-        VTABLE_set_number_native(INTERP, dest,

-                DYNSELF.get_number() + value);

-        return dest;

-    }

-

-    void i_add_float (FLOATVAL value) {

-        VTABLE_set_number_native(INTERP, SELF,

-            DYNSELF.get_number() + value);

-    }

-

 /*

 

 =item C<PMC* subtract (PMC* value, PMC* dest)>

Reply via email to