Example #1
0
def _best_match(func_wrapper, argtypes):
    overloaded = func_wrapper.resolve_dispatcher()
    argtypes = [to_blaze(t) for t in argtypes]

    overload = overloading.best_match(overloaded, argtypes)
    scope = determine_scope(overload.func)
    signature = resolve(overload.resolved_sig, scope, {})
    return (overload.func, signature, overload.kwds)
Example #2
0
def _best_match(func_wrapper, argtypes):
    overloaded = func_wrapper.resolve_dispatcher()
    argtypes = [to_blaze(t) for t in argtypes]

    overload = overloading.best_match(overloaded, argtypes)
    scope = determine_scope(overload.func)
    signature = resolve(overload.resolved_sig, scope, {})
    return (overload.func, signature, overload.kwds)
Example #3
0
    def test_loop(self):
        def loop(a, b):
            result = a
            while a > b:
                result = b
            return result

        f, context, signature = get(loop, [int32, int32])
        self.assertEqual(signature, Function[int32, int32, int32])

        # TODO: Make blaze unit types instantiations of generic type constructors
        type = context[findop(f, 'call')]
        type = resolve(type, globals(), {})
Example #4
0
    def test_loop(self):
        def loop(a, b):
            result = a
            while a > b:
                result = b
            return result

        f, context, signature = get(loop, [int32, int32])
        self.assertEqual(signature, Function[int32, int32, int32])

        # TODO: Make blaze unit types instantiations of generic type constructors
        type = context[findop(f, 'call')]
        type = resolve(type, globals(), {})
Example #5
0
def populate_dispatcher(dispatcher, overloads):
    """
    Populate dispatcher with the given overloads.
    """
    from flypy.typing import resolve, to_blaze

    for py_func, signature, kwds in overloads:
        if not signature:
            signature = dummy_signature(py_func)
        else:
            # Resolve the signature in its scope, that is resolve any dummy
            # blaze TypeConstructor objects to the types from the scope
            scope = determine_scope(py_func)
            bound = {} # TODO:
            signature = resolve(signature, scope, bound)
            # Use blaze's coercion rules for now
            signature = to_blaze(signature)

        overload(signature, dispatcher=dispatcher, **kwds)(py_func)
Example #6
0
def populate_dispatcher(dispatcher, overloads):
    """
    Populate dispatcher with the given overloads.
    """
    from flypy.typing import resolve, to_blaze

    for py_func, signature, kwds in overloads:
        if not signature:
            signature = dummy_signature(py_func)
        else:
            # Resolve the signature in its scope, that is resolve any dummy
            # blaze TypeConstructor objects to the types from the scope
            scope = determine_scope(py_func)
            bound = {}  # TODO:
            signature = resolve(signature, scope, bound)
            # Use blaze's coercion rules for now
            signature = to_blaze(signature)

        overload(signature, dispatcher=dispatcher, **kwds)(py_func)
Example #7
0
def _resolve(t, bound):
    return resolve(t, globals(), bound)
Example #8
0
def _resolve(t, bound):
    return resolve(t, globals(), bound)