Exemplo n.º 1
0
    def finalize(self):
        super().finalize()

        if Identifier.constructor() not in self.names:  # Add implicit constructor
            self.children.insert(0, MethodDefinition.empty_constructor(self))

        if self.extends and self.extends.untyped in definitions.INTERNAL_SOURCES:
            self.children.insert(0, MemberDefinition(Identifier.super(), self.extends).deriving_from(self))
Exemplo n.º 2
0
    def finalize(self):
        if not self.is_constructor():
            return super().finalize()

        for descendant in self.descendants:
            if isinstance(
                    descendant,
                    MethodCall) and descendant.target[0] == Identifier.super():
                descendant.replace(
                    AssignmentOperation(
                        AssignmentOperation.REASSIGNMENT,
                        NamedAccess([Identifier.self(),
                                     Identifier.super()]),
                        MethodCall(NamedAccess(
                            [self.parent.extends,
                             Identifier.constructor()]),
                                   descendant.arguments,
                                   is_captured=True).deriving_from(
                                       self)).deriving_from(descendant))

        super().finalize()