Ejemplo n.º 1
0
    def visit_ExceptHandler(self, node):
        name = node.name
        if self.name_is_in_lscope(name):
            NodeError.warn_msg(
                node, ('exception var [%s] hides sym in outer scope' % name))

            # assume all exceptions are classical
            self.add_type_binding(subnode, subnode.id, QGL2.CLASSICAL)
        pass
Ejemplo n.º 2
0
    def visit_With(self, node):
        """
        TODO: this is incomplete; we just assume that with-as variables
        are all classical.  We don't attempt to infer anything about their
        type.  (This is likely to be true in most cases, however)
        """

        for item in node.items:
            if not item.optional_vars:
                continue

            for subnode in ast.walk(item.optional_vars):
                if isinstance(subnode, ast.Attribute):
                    # This is a fatal error and we don't want to confuse
                    # ourselves by trying to process the ast.Name
                    # nodes beneath
                    #
                    name_text = pyqgl2.importer.collapse_name(subnode)
                    NodeError.fatal_msg(
                        subnode, ('with-as var [%s] is not local' % name_text))

                elif isinstance(subnode, ast.Name):
                    name = subnode.id

                    DebugMsg.log('GOT WITH (%s)' % name)

                    # Warn the user if they're doing something that's
                    # likely to provoke an error
                    #
                    if self.name_is_in_lscope(name):
                        NodeError.warn_msg(
                            subnode,
                            ('with-as var [%s] hides sym in outer scope' %
                             name))
                    self.add_type_binding(subnode, subnode.id, QGL2.CLASSICAL)

        self.visit_body(node.body)