コード例 #1
0
    def mk_struct_sort2(self, t):
        # Z3 tuples don't _appear_ to be exported to python. Therefore we have
        # to funnel some pointers into it manually, via ctypes.
        num_fields = len(t.member_names)

        # Create names for fields. The multiplication syntax is ctypes way to
        # allocate an array.
        ast_vec = (z3.Symbol * num_fields)()
        i = 0
        for x in t.member_names:
            ast_vec[i] = z3.Symbol(x.as_string())
            i += 1

        # Create types. These are Z3sorts, that contain a z3.SortRef, which
        # in turn contains a z3.Sort. The latter is what we need to funnel
        # into ctype function call.
        sort_vec = (z3.Sort * num_fields)()
        sub_sorts = [self.convert_sort(x) for x in t.members]
        i = 0
        for i in range(len(sub_sorts)):
            sort_vec[i] = sub_sorts[i].sort.ast

        # Name for this type
        z3_sym = z3.Symbol(t.typename.as_string())

        # Allocate output ptrs -- function for creating the object, and for
        # projecting fields.
        ret_decl = (z3.FuncDecl * 1)()
        proj_decl = (z3.FuncDecl * num_fields)()
        sort_ref = z3.Z3_mk_tuple_sort(self.ctx.ctx, z3_sym, num_fields,
                                       ast_vec, sort_vec, ret_decl, proj_decl)

        # Reference management: output operands start with zero references IIRC,
        # We want to keep a handle on the returned sort_ref, and the FuncDecl
        # typed ast, for creation of new tuples. The projection decls need to
        # be kept so that we can extract fields from the tuple.
        finsort = Z3sort(z3.BoolSortRef(sort_ref, self.ctx),
                         esbmc.solve.smt_sort_kind.struct)
        proj_decls = [z3.FuncDeclRef(x) for x in proj_decl]
        finsort.decl_ref = z3.FuncDeclRef(ret_decl[0])
        finsort.proj_decls = proj_decls
        finsort.sub_sorts = sub_sorts
        return finsort
コード例 #2
0
ファイル: z3str2.py プロジェクト: sukwon0709/Z3-str
def string_concat():
    ctx = z3.main_ctx()
    decl = z3strlib.z3str_concat_decl()
    return z3.FuncDeclRef(decl, ctx)
コード例 #3
0
ファイル: z3str2.py プロジェクト: sukwon0709/Z3-str
def string_lastindexof():
    ctx = z3.main_ctx()
    decl = z3strlib.z3str_lastindexof_decl()
    return z3.FuncDeclRef(decl, ctx)
コード例 #4
0
ファイル: z3str2.py プロジェクト: sukwon0709/Z3-str
def string_replace():
    ctx = z3.main_ctx()
    decl = z3strlib.z3str_replace_decl()
    return z3.FuncDeclRef(decl, ctx)
コード例 #5
0
ファイル: z3str2.py プロジェクト: sukwon0709/Z3-str
def string_endswith():
    ctx = z3.main_ctx()
    decl = z3strlib.z3str_endswith_decl()
    return z3.FuncDeclRef(decl, ctx)
コード例 #6
0
ファイル: z3str2.py プロジェクト: sukwon0709/Z3-str
def string_indexof2():
    ctx = z3.main_ctx()
    decl = z3strlib.z3str_indexof2_decl()
    return z3.FuncDeclRef(decl, ctx)
コード例 #7
0
ファイル: z3str2.py プロジェクト: sukwon0709/Z3-str
def string_substring():
    ctx = z3.main_ctx()
    decl = z3strlib.z3str_substring_decl()
    return z3.FuncDeclRef(decl, ctx)