expr_inferrer.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Typpete 作者: caterinaurban 项目源码 文件源码
def binary_operation_type(left_type, op, right_type, lineno, solver):
    """Infer the type of a binary operation result"""
    if isinstance(op, ast.Add):
        inference_func = _infer_add
    elif isinstance(op, ast.Mult):
        inference_func = _infer_mult
    elif isinstance(op, ast.Div):
        inference_func = _infer_div
    elif isinstance(op, (ast.BitOr, ast.BitXor, ast.BitAnd)):
        return _infer_bitwise(left_type, right_type, op, lineno, solver)
    else:
        return _infer_arithmetic(left_type, right_type, op, lineno, solver)

    return inference_func(left_type, right_type, lineno, solver)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号