[pypy-svn] r18326 - pypy/dist/pypy/translator/js

ericvrp at codespeak.net ericvrp at codespeak.net
Mon Oct 10 10:45:05 CEST 2005


Author: ericvrp
Date: Mon Oct 10 10:45:04 2005
New Revision: 18326

Modified:
   pypy/dist/pypy/translator/js/codewriter.py
   pypy/dist/pypy/translator/js/opwriter.py
Log:
Simplification of shift operations. They no longer need to be special-cased.
One more test passes.


Modified: pypy/dist/pypy/translator/js/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/js/codewriter.py	(original)
+++ pypy/dist/pypy/translator/js/codewriter.py	Mon Oct 10 10:45:04 2005
@@ -133,14 +133,11 @@
     def binaryop(self, name, targetvar, type_, ref1, ref2):
         arithmetic = ('*', '/', '+', '-', '%', '^', '&', '|', '<<', '>>')
         comparison = ('<', '<=', '==', '!=', '>=', '>')
-        if name in arithmetic or name in comparison:
+        if name in arithmetic or name in comparison:    #XXX this should now always true
             self.append("%(targetvar)s = %(ref1)s %(name)s %(ref2)s" % locals())
         else:
             self.llvm("%s = %s %s %s, %s" % (targetvar, name, type_, ref1, ref2))
 
-    def shiftop(self, name, targetvar, type_, ref1, ref2):
-        self.llvm("%s = %s %s %s, ubyte %s" % (targetvar, name, type_, ref1, ref2))
-
     def call(self, targetvar, returntype, functionref, argrefs, argtypes, label=None, except_label=None):
         args = ", ".join(["%s %s" % item for item in zip(argtypes, argrefs)])
         if except_label:

Modified: pypy/dist/pypy/translator/js/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/js/opwriter.py	(original)
+++ pypy/dist/pypy/translator/js/opwriter.py	Mon Oct 10 10:45:04 2005
@@ -15,6 +15,8 @@
                          'int_and': '&',
                          'int_or': '|',
                          'int_xor': '^',
+                         'int_lshift': '<<',
+                         'int_rshift': '>>',
                          'int_lt': '<',
                          'int_le': '<=',
                          'int_eq': '==',
@@ -30,6 +32,8 @@
                          'uint_and': '&',
                          'uint_or': '|',
                          'uint_xor': '^',
+                         'uint_lshift': '<<',
+                         'uint_rshift': '>>',
                          'uint_lt': '<',
                          'uint_le': '<=',
                          'uint_eq': '==',
@@ -60,13 +64,6 @@
                          'ptr_ne': '!=',
                          }
 
-    shift_operations  = {'int_lshift': '<<',
-                         'int_rshift': '>>',
-
-                         'uint_lshift': '<<',
-                         'uint_rshift': '>>',
-                         }
-
 
     char_operations  = {'char_lt': '<',
                         'char_le': '<=',
@@ -88,8 +85,6 @@
         else:
             if op.opname in self.binary_operations:
                 self.binaryop(op)
-            elif op.opname in self.shift_operations:
-                self.shiftop(op)
             elif op.opname in self.char_operations:
                 self.char_binaryop(op)
             elif op.opname.startswith('cast_'):
@@ -211,21 +206,6 @@
         self.codewriter.cast(c2, "sbyte", self.db.repr_arg(op.args[1]), "ubyte")
         self.codewriter.binaryop(name, res, "ubyte", c1, c2)
 
-
-    def shiftop(self, op):
-        name = self.shift_operations[op.opname]
-        assert len(op.args) == 2
-        if isinstance(op.args[1], Constant):
-            tmpvar = self.db.repr_arg(op.args[1])
-        else:
-            tmpvar = self.db.repr_tmpvar()
-            self.codewriter.cast(tmpvar, self.db.repr_arg_type(op.args[1]), self.db.repr_arg(op.args[1]), 'ubyte')
-        self.codewriter.shiftop(name,
-                                self.db.repr_arg(op.result),
-                                self.db.repr_arg_type(op.args[0]),
-                                self.db.repr_arg(op.args[0]),
-                                tmpvar)
-
     def cast_char_to_int(self, op):
         " works for all casts "
         assert len(op.args) == 1



More information about the Pypy-commit mailing list