Beispiel #1
0
        def flush(self):
            self.flush_state(whosgranddaddy())

            # At this point we have both lhs and rhs plus three flags and can
            # make a decision about what to create.

            def create_attr_static(t):
                self.current_class().AddAttribute(attrname=t,
                                                  attrtype=['static'])
                return t

            def create_attr(t):
                if (t == '__class__') and len(self.lhs) >= 3:
                    t = self.lhs[2]
                    self.current_class().AddAttribute(attrname=t,
                                                      attrtype=['static'])
                else:
                    self.current_class().AddAttribute(attrname=t,
                                                      attrtype=['normal'])
                return t

            def create_attr_many(t):
                self.current_class().AddAttribute(attrname=t,
                                                  attrtype=['normal', 'many'])
                return t

            def create_attr_please(t):
                if self.made_append_call:
                    t = create_attr_many(t)
                else:
                    t = create_attr(t)
                return t

            if self.made_assignment or self.made_append_call:

                if self.in_class_static_area():
                    t = create_attr_static(self.lhs[0])
                elif self.in_method_in_class_area(
                ) and self.lhs[0] == 'self' and len(self.lhs) > 1:
                    t = create_attr_please(self.lhs[1])
                else:
                    pass  # in module area

                if self.lhs[0] == 'self' and len(self.rhs) > 0:
                    ra = RhsAnalyser(visitor=self)
                    if ra.is_rhs_reference_to_a_class():
                        self.add_composite_dependency((t, ra.rhs_ref_to_class))

            self.init_lhs_rhs()
            #self.flush_state()
            self.write("<hr>", mynote=2)
        def flush(self):
            self.flush_state(whosgranddaddy())
            
            # At this point we have both lhs and rhs plus three flags and can
            # make a decision about what to create.
        
            def create_attr_static(t):
                self.current_class().AddAttribute(attrname=t, attrtype=['static'])
                return t
            def create_attr(t):
                if (t == '__class__') and len(self.lhs) >= 3:
                    t = self.lhs[2]
                    self.current_class().AddAttribute(attrname=t, attrtype=['static'])
                else:
                    self.current_class().AddAttribute(attrname=t, attrtype=['normal'])
                return t
            def create_attr_many(t):
                self.current_class().AddAttribute(attrname=t, attrtype=['normal', 'many'])
                return t
            def create_attr_please(t):
                if self.made_append_call:
                    t = create_attr_many(t)
                else:
                    t = create_attr(t)
                return t

            if self.made_assignment or self.made_append_call:
                
                if self.in_class_static_area():
                    t = create_attr_static(self.lhs[0])
                elif self.in_method_in_class_area() and self.lhs[0] == 'self' and len(self.lhs) > 1:
                    t = create_attr_please(self.lhs[1])
                else:
                    pass # in module area
          
                if self.lhs[0] == 'self' and len(self.rhs) > 0:
                    ra = RhsAnalyser(visitor=self)
                    if ra.is_rhs_reference_to_a_class():
                        self.add_composite_dependency((t, ra.rhs_ref_to_class))
                        
            self.init_lhs_rhs()
            #self.flush_state()
            self.write("<hr>", mynote=2)
Beispiel #3
0
    def flush(self):
        """
            Flush is called after:
                * newlines,
                * ends of classes
                * end of functions
                * should be more?

            It is only interested in whether an assignment has been made or an append call has been made
            in order to create the relevant attribute and type (one or many).
            """

        if DEBUGINFO():
            # this is cripplingly slow when bundled in pyinstaller
            self.flush_state(whosgranddaddy())
        else:
            self.flush_state("")

        # At this point we have both lhs and rhs plus three flags and can
        # make a decision about what to create.

        def create_attr_static(t):
            self.current_class().AddAttribute(attrname=t, attrtype=["static"])
            return t

        def create_attr(t):
            if (t == "__class__") and len(self.lhs) >= 3:
                t = self.lhs[2]
                self.current_class().AddAttribute(attrname=t,
                                                  attrtype=["static"])
            else:
                self.current_class().AddAttribute(attrname=t,
                                                  attrtype=["normal"])
            return t

        def create_attr_many(t):
            self.current_class().AddAttribute(attrname=t,
                                              attrtype=["normal", "many"])
            return t

        def create_attr_please(t):
            if self.made_append_call:
                t = create_attr_many(t)
            else:
                t = create_attr(t)
            return t

        if self.made_assignment or self.made_append_call:

            if self.in_class_static_area():
                t = create_attr_static(self.lhs[0])
            elif self.in_method_in_class_area(
            ) and self.lhs[0] == "self" and len(self.lhs) > 1:
                t = create_attr_please(self.lhs[1])
            else:
                pass  # in module area

            if self.lhs[0] == "self" and len(self.rhs) > 0:
                ra = RhsAnalyser(visitor=self)
                if ra.is_rhs_reference_to_a_class():
                    self.add_composite_dependency((t, ra.rhs_ref_to_class))

        self.init_lhs_rhs()
        # self.flush_state()
        self.write("<hr>", mynote=2)