Commits

Stephen Tu committed bbe1925

more general literal assignment - handle the ret values from builtin functions
like open(), hash(), etc

Comments (0)

Files changed (1)

pypy/interpreter/astcompiler/codegen.py

     _DICT_TYPE    = 7
     _SET_TYPE     = 8
     _TUPLE_TYPE   = 9
+    _FILE_TYPE    = 10
 
     def _effective_literal_type(self, value):
         konst_type = self._literal_type(value)
             oname = self._unravel_instr_sequence(value.func)
             if oname == 'set':
                 return self._SET_TYPE
-            elif oname == 'list':
+
+            elif oname == 'issubclass' or \
+                 oname == 'isinstance' or \
+                 oname == 'hasattr' or \
+                 oname == 'callable' or \
+                 oname == 'any' or \
+                 oname == 'all':
+                return self._BOOL_TYPE
+
+            elif oname == 'list' or \
+                 oname == 'range' or \
+                 oname == 'zip' or \
+                 oname == 'dir':
                 return self._LIST_TYPE
-            elif oname == 'tuple':
+
+            elif oname == 'tuple' or \
+                 oname == 'coerce' or \
+                 oname == 'divmod':
                 return self._TUPLE_TYPE
-            elif oname == 'dict':
+
+            elif oname == 'dict' or \
+                 oname == 'globals' or \
+                 oname == 'locals':
                 return self._DICT_TYPE
-            elif oname == 'int':
+
+            elif oname == 'int' or \
+                 oname == 'id' or \
+                 oname == 'hash' or \
+                 oname == 'len' or \
+                 oname == 'ord':
                 return self._INT_TYPE
-            elif oname == 'float':
+
+            elif oname == 'float' or \
+                 oname == 'round' or \
+                 oname == 'abs' or \
+                 oname == 'cmp':
                 return self._FLOAT_TYPE
-            elif oname == 'str' or oname == 'chr':
+
+            elif oname == 'str' or \
+                 oname == 'bytes' or \
+                 oname == 'unicode' or \
+                 oname == 'chr' or \
+                 oname == 'unichr' or \
+                 oname == 'hex' or \
+                 oname == 'oct' or \
+                 oname == 'intern' or \
+                 oname == 'repr' or \
+                 oname == 'format' or \
+                 oname == 'bin' or \
+                 oname == 'raw_input':
                 return self._STR_TYPE
-            elif oname == 'ord':
-                return self._INT_TYPE
+
+            elif oname == 'open' or \
+                 oname == 'file':
+                return self._FILE_TYPE
+
         return self._UNKNOWN_TYPE
 
     _TypeToFeatureName = {
         _DICT_TYPE  : 'dict_literal',
         _SET_TYPE   : 'set_literal',
         _TUPLE_TYPE : 'tuple_literal',
+        _FILE_TYPE  : 'file_literal',
     }
 
     def _assignment_like(self, target, value, aug):