示例#1
0
    def visit_generic(self, ast):
        """
        Apply Times across Durations.
        """

        if hasfield(ast, "duration") and self.scale != Fraction(1, 1):
            duration = int(ast.duration * self.scale)
            ast = ast._replace(duration=duration)

        return ast, True
示例#2
0
    def visit_generic(self, ast):
        """
        Simplify and fill in durations along an AST.
        """

        if hasfield(ast, "duration"):
            duration = self.fill_duration(ast.duration)
            duration = self.undot_duration(duration.length, duration.dots)
            ast = ast._replace(duration=duration)

        return ast, True
示例#3
0
        def do_peepholes(ast):
            if not hasfield(ast, "exprs"):
                return

            i = 0
            lt = len(types)
            while len(ast.exprs) >= i + lt:
                matched = False
                window = ast.exprs[i:i + lt]
                if all(isinstance(*args) for args in zip(window, types)):
                    ast.exprs[i:i + lt], matched = f(*window)

                if not matched:
                    i += 1
示例#4
0
    def visit_generic(self, node):
        if hasfield(node, "exprs"):
            exprs = _slurry(node.exprs).slurify()
            node = node._replace(exprs=exprs)

        return node, True