Skip to content

Commit

Permalink
Merge pull request #63 from nicdard/fix/api-types
Browse files Browse the repository at this point in the history
fix: ignore seeds that are not supported by ffg api
  • Loading branch information
muchang committed Feb 20, 2023
2 parents eb937c2 + a28f3ef commit f38bb10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
26 changes: 17 additions & 9 deletions yinyang/src/mutators/SemanticFusion/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,14 @@ def generate_fusion_function_templates(
and new fusion functions to fuse them. Returns the templates
used to perform the fuse step.
"""
# Solve BitVec problem with a best effort approach:
# TODO Solve BitVec problem with a best effort approach:
# try to generate formulas until you get the right bitvector type.
tlist1 = _type_list(global_vars1)
tlist2 = _type_list(global_vars2)
templates = {}

for t1 in tlist1:
type1 = tlist1[t1]
for t2 in tlist2:
type2 = tlist2[t2]
theories = [type2ffg(type1), type2ffg(type2)]
options1 = _map_to_ffg_theories(global_vars1)
options2 = _map_to_ffg_theories(global_vars2)
for op1 in options1:
for op2 in options2:
theories = [op1, op2]
gen_configuration.set_available_theories(theories)
operator_types = gen_configuration.get_theories()
root_type = random.choice(operator_types)
Expand All @@ -268,3 +265,14 @@ def generate_fusion_function_templates(
populate_template_map(templates, template)

return templates


def _map_to_ffg_theories(global_vars):
"""
Filter only theories supported by ffg and maps them
to options for it to be used in generate_tree.
"""
ts = _type_list(global_vars)
options = [type2ffg(ts[t]) for t in ts]
options = list(filter(lambda t: t is not None, options))
return options
5 changes: 3 additions & 2 deletions yinyang/src/parsing/Types.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ def type2ffg(typ):
return INT_OPTION
elif typ == STRING_TYPE:
return STRING_OPTION
elif isinstance(typ, BITVECTOR_OPTION):
elif isinstance(typ, BITVECTOR_TYPE):
# TODO: manage also the size
return BITVECTOR_OPTION
else:
raise ValueError(f"The type {typ} is not supported by the generator")
# If the type is not supported by ffg.
return None


def sort2type(sort):
Expand Down

0 comments on commit f38bb10

Please sign in to comment.