当前位置: 首页>>代码示例>>Python>>正文


Python z3.is_true方法代码示例

本文整理汇总了Python中z3.is_true方法的典型用法代码示例。如果您正苦于以下问题:Python z3.is_true方法的具体用法?Python z3.is_true怎么用?Python z3.is_true使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在z3的用法示例。


在下文中一共展示了z3.is_true方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: try_make_simple_if_else

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def try_make_simple_if_else(
        self, node1, node2, nodes_to_check, nodes_to_remove
    ):

        log_debug("try_make_simple_if_else")

        cond1 = node1.condition
        cond2 = node2.condition

        if is_true(simplify(cond1 == Not(cond2))):
            log_debug(f"found a simple if/else match")
            if cond1.decl().name() == "not":
                node2[False] = node1[True]
                nodes_to_check.remove(node2)
                nodes_to_remove.append(node1)
            else:
                node1[False] = node2[True]
                nodes_to_remove.append(node2)

            return True

        return False 
开发者ID:joshwatson,项目名称:f-ing-around-with-binaryninja,代码行数:24,代码来源:mlil_ast.py

示例2: _convert_to_while_loop

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def _convert_to_while_loop(
        self, node: MediumLevelILAstLoopNode, while_condition
    ):
        log_debug(f"{node} is a while loop")
        node.loop_type = "while"
        node.condition = reduce(
            And, Tactic("ctx-solver-simplify")(Not(while_condition))[0]
        )

        break_cond = node.body.nodes[0]

        if break_cond[False] is not None:
            node.body._nodes[0] = break_cond[False]

        # Flatten condition nodes that have the same condition
        # as the loop condition
        for idx, child in enumerate(node.body.nodes):
            if (
                isinstance(child, MediumLevelILAstCondNode)
                and is_true(simplify(child.condition == node.condition))
                and child[False] is None
            ):
                node.body._nodes[idx] = child[True] 
开发者ID:joshwatson,项目名称:f-ing-around-with-binaryninja,代码行数:25,代码来源:mlil_ast.py

示例3: to_bool

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def to_bool(e : z3.AstRef):
    """
    If `e` is a boolean literal, return its value (True or False).
    Otherwise, return None.
    """
    if z3.is_true(e):
        return True
    if z3.is_false(e):
        return False
    return None 
开发者ID:CozySynthesizer,项目名称:cozy,代码行数:12,代码来源:solver.py

示例4: try_make_complex_if_else

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def try_make_complex_if_else(
        self, parent, node1, node2, nodes_to_check, nodes_to_remove
    ):
        log_debug("try_make_complex_if_else")
        is_complex_if_else = self.find_c_and_R(
            node1.condition, node2.condition
        )

        if not is_complex_if_else:
            return False
        else:
            c, R = is_complex_if_else

        # if we get here, we have a complex if/else
        new_if_else_node = MediumLevelILAstCondNode(
            self, c, node1._condition_il, node1[True], node2[True]
        )

        log_debug(f"R is currently {R}")

        new_seq_node = MediumLevelILAstSeqNode(self, [new_if_else_node])

        if is_true(R):
            new_cond_node = new_if_else_node
        else:
            new_cond_node = MediumLevelILAstCondNode(
                self, R, node1._condition_il, new_seq_node
            )

        log_debug(f"new_cond_node: {new_cond_node}")

        if node1 in parent.nodes:
            node1_idx = parent.nodes.index(node1)

            parent._nodes[node1_idx] = new_cond_node
            nodes_to_remove.append(node2)
            nodes_to_check.remove(node2)
        else:
            log_debug(f"{node1} not in parent.nodes") 
开发者ID:joshwatson,项目名称:f-ing-around-with-binaryninja,代码行数:41,代码来源:mlil_ast.py

示例5: evaluate

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def evaluate(self, t):
    s = self.solver.model().eval(t.z3Node())
    assert z3.is_true(s) or z3.is_false(s)
    return z3.is_true(s) 
开发者ID:jeanqasaur,项目名称:jeeves,代码行数:6,代码来源:Z3.py

示例6: create_new_node_from_region

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def create_new_node_from_region(
        self,
        bb: MediumLevelILBasicBlock,
        block: MediumLevelILBasicBlock,
        sub_region: MediumLevelILAstNode,
        current_node: MediumLevelILAstNode,
        cases: dict,
        nodes: list
    ):
        log_debug(
            f"create_new_node_from_region({bb}, {block}, {sub_region}, {current_node})"
        )
        reaching_constraint = self._reaching_constraints.get((bb.start, block.start))

        if is_true(reaching_constraint):
            reaching_constraint = None

        if reaching_constraint is not None and self.any_node_dominated(
            sub_region, block, bb
        ):
            reaching_constraint = None

        if reaching_constraint is not None:
            if sub_region.type == "loop":
                sub_region = MediumLevelILAstSeqNode(self, [sub_region])

            # This is now a condition node if a reaching constraint exists
            log_debug(
                f"    Creating new CondNode with {sub_region} {reaching_constraint}\n\n"
            )
            new_node = MediumLevelILAstCondNode(
                self,
                reaching_constraint,
                block.incoming_edges[0].source[-1],
                sub_region,
            )

        else:
            new_node = sub_region

        if new_node is not None:
            if current_node.type != "switch":
                nodes.append(new_node)
            else:
                if block in cases:
                    if current_node.block not in new_node.block.dominators:
                        case = ["default"]
                    else:
                        case = cases[block]

                    current_node.append(
                        MediumLevelILAstCaseNode(self, case, [new_node])
                    )
                else:
                    return False

        return True 
开发者ID:joshwatson,项目名称:f-ing-around-with-binaryninja,代码行数:59,代码来源:mlil_ast.py

示例7: _convert_to_do_while_loop

# 需要导入模块: import z3 [as 别名]
# 或者: from z3 import is_true [as 别名]
def _convert_to_do_while_loop(
        self, node: MediumLevelILAstLoopNode, dowhile_condition
    ):
        log_debug(f"{node} is a do while loop")
        node.loop_type = "dowhile"
        node.condition = reduce(
            And, Tactic("ctx-solver-simplify")(Not(dowhile_condition))[0]
        )

        break_cond = node.body.nodes[-1]

        if break_cond[False] is not None:
            node.body._nodes[-1] = break_cond[False]
        else:
            node.body._nodes.pop()

        # Flatten condition nodes that have the same condition
        # as the loop condition
        for idx, child in enumerate(node.body.nodes):
            if (
                isinstance(child, MediumLevelILAstCondNode)
                and is_true(simplify(child.condition == node.condition))
                and child[False] is None
            ):
                node.body._nodes[idx] = child[True]

            log_debug(f"Checking {child} for break condition")
            if isinstance(child, MediumLevelILAstCondNode) and is_false(
                simplify(And(child.condition, node.condition))
            ):
                break_instr = child[True].nodes[-1].block[-1]

                child[True]._nodes.append(
                    MediumLevelILAstBreakNode(
                        self, break_instr.instr_index, break_instr.address
                    )
                )

                new_loop_condition = self._split_break_condition(
                    node.condition, child.condition
                )

                if new_loop_condition is not None:
                    log_debug(f"new_loop_condition is {new_loop_condition}")
                    node.condition = new_loop_condition 
开发者ID:joshwatson,项目名称:f-ing-around-with-binaryninja,代码行数:47,代码来源:mlil_ast.py


注:本文中的z3.is_true方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。