1. Stephen Tu
  2. mino-pypy

Commits

Stephen Tu  committed 63fe50e

handle a few more features

  • Participants
  • Parent commits 26996dd
  • Branches default

Comments (0)

Files changed (1)

File pypy/interpreter/astcompiler/codegen.py

View file
             self._record_binary_feature(node, 'used_as_ret_val')
         ast.GenericASTVisitor.visit_Return(self, node)
 
+    def _assign_helper(self, target, value):
+        # handle target = value
+        self._assignment_like(target, value, False)
+        self._note_assignment(target, value)
+        if isinstance(target, ast.Tuple):
+            # this is the case of:
+            # x, y = rhs
+            self._record_binary_feature(value, 'used_as_rhs_multiassign')
+        else:
+            # check for:
+            # x = SomeName()
+            #
+            # since we don't know if SomeName is actually a type or function,
+            # we can only emit a feature here, instead of giving it a true
+            # assigment like in the literal case
+            if isinstance(value, ast.Call):
+                oname = self._unravel_instr_sequence(value.func)
+                if not oname:
+                    return
+                if ord(oname[0]) >= ord('A') and \
+                   ord(oname[0]) <= ord('Z'):
+                    self._record_binary_feature(target, 'assigned_cap_symbol')
+
     def visit_Assign(self, node):
         #self._break_if_file_matches('fooassign.py')
-        ntargets = len(node.targets)
-        if ntargets == 1:
-            target = node.targets[0]
-            self._assignment_like(target, node.value, False)
-            self._note_assignment(target, node.value)
-            if isinstance(target, ast.Tuple):
-                # this is the case of:
-                # x, y = rhs
-                self._record_binary_feature(node.value, 'used_as_rhs_multiassign')
-        # XXX: handle ntarget > 1 later. this happens when we have
-        # x = y = rhs, in which case targets = [Name(x), Name(y)]
-
+        for target in node.targets:
+            self._assign_helper(target, node.value)
         ast.GenericASTVisitor.visit_Assign(self, node)
 
     def visit_AugAssign(self, node):