當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。