예제 #1
0
def opgrouper(visitor, prefix='op_'):
    """
    op_add, op_mul, ... -> op_binary
    """
    handlers = mergedicts(unop_handlers(visitor.op_unary, prefix),
                          binop_handlers(visitor.op_binary, prefix),
                          compare_handlers(visitor.op_compare, prefix))
    return combine(visitor, handlers)
예제 #2
0
    def test_combinator(self):
        visitor = SampleVisitor()
        def op_blah(op):
            visitor.recorded.append(op.opcode)

        comb = combine(visitor, {'op_blah': op_blah})
        with self.b.at_front(self.entry):
            self.b.emit(Op('blah', None, []))
        visit(comb, self.f)
        self.eq(visitor.recorded, ['blah', 'mul'])
예제 #3
0
    def test_combinator(self):
        visitor = SampleVisitor()

        def op_blah(op):
            visitor.recorded.append(op.opcode)

        comb = combine(visitor, {"op_blah": op_blah})
        with self.b.at_front(self.entry):
            self.b.emit(Op("blah", None, []))
        visit(comb, self.f)
        self.eq(visitor.recorded, ["blah", "mul"])
예제 #4
0
def verify_semantics(func, env=None):
    verifier = combine(Verifier(), env and env.get("verify.handlers"))
    visit(verifier, func)
예제 #5
0
def verify_semantics(func, env=None):
    verifier = combine(Verifier(), env and env.get("verify.handlers"))
    visit(verifier, func)