Skip to content

Commit c2fe31d

Browse files
author
thientc
committed
fix function name
1 parent 400e183 commit c2fe31d

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed
Binary file not shown.
139 Bytes
Binary file not shown.

src/python/futag-package/src/futag/generator.py

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,40 @@ def __gen_var_function(self, func_param_name: str, func):
982982
param_id += 1
983983
param_list.append(curr_name)
984984

985-
function_call = "//GEN_VAR_FUNCTION\n " + func["return_type"] + " " + func_param_name + \
986-
" = " + func["qname"] + \
987-
"(" + ",".join(param_list)+");\n"
985+
found_parent = None
986+
if func["func_type"] in [FUNC_CXXMETHOD, FUNC_CONSTRUCTOR, FUNC_DEFAULT_CONSTRUCTOR]:
987+
# Find parent class
988+
for r in self.target_library["records"]:
989+
if r["hash"] == func["parent_hash"]:
990+
found_parent = r
991+
break
992+
if not found_parent:
993+
self.gen_this_function = False
994+
class_name = found_parent["qname"]
995+
if func["func_type"] in [FUNC_CONSTRUCTOR, FUNC_DEFAULT_CONSTRUCTOR]:
996+
function_call = " //declare the RECORD and call constructor\n"
997+
function_call +=" " + class_name.replace("::(anonymous namespace)", "") + func_param_name + "("+ ",".join(param_list)+");\n"
998+
else:
999+
# Find default constructor
1000+
# TODO: add code for other constructors
1001+
found_default_constructor = False
1002+
for fu in self.target_library["functions"]:
1003+
if fu["parent_hash"] == func["parent_hash"] and fu["func_type"] == FUNC_DEFAULT_CONSTRUCTOR:
1004+
found_default_constructor = True
1005+
1006+
# TODO: add code for other constructors!!!
1007+
if not found_default_constructor:
1008+
self.gen_this_function = False
1009+
function_call = " //declare the RECORD first\n"
1010+
function_call += " " + class_name.replace("::(anonymous namespace)", "") + " " + func_param_name + ";\n"
1011+
# call the method
1012+
function_call += " //METHOD CALL\n"
1013+
function_call += " " + func_param_name + "." + func["name"]+"("+ ",".join(param_list)+");\n"
1014+
1015+
else:
1016+
function_call = "//GEN_VAR_FUNCTION\n " + func["return_type"] + " " + func_param_name + \
1017+
" = " + func["qname"] + \
1018+
"(" + ",".join(param_list)+");\n"
9881019

9891020
gen_dict["gen_lines"] += [function_call]
9901021
return gen_dict
@@ -2208,7 +2239,11 @@ def gen_targets(self, anonymous: bool = False):
22082239
self.param_list = []
22092240
self.curr_function = func
22102241
self.curr_func_log = ""
2211-
self.__gen_target_function(func, 0)
2242+
if "(anonymous" in func["qname"]:
2243+
self.__gen_anonymous_function(func, 0)
2244+
else:
2245+
self.__gen_target_function(func, 0)
2246+
# self.__gen_target_function(func, 0)
22122247

22132248
# For C++, Declare object of class and then call the method
22142249
if func["access_type"] == AS_PUBLIC and func["fuzz_it"] and func["func_type"] in [FUNC_CXXMETHOD, FUNC_CONSTRUCTOR, FUNC_DEFAULT_CONSTRUCTOR, FUNC_GLOBAL, FUNC_STATIC] and (not "::operator" in func["qname"]):
@@ -2518,7 +2553,7 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
25182553
+ " fuzz-driver(s)\n"
25192554
)
25202555

2521-
def compile_targets_new(self, workers: int = 4, keep_failed: bool = False, extra_include: str = "", extra_dynamiclink: str = "", flags: str = "", coverage: bool = False):
2556+
def compile_all_targets(self, workers: int = 4, keep_failed: bool = False, extra_include: str = "", extra_dynamiclink: str = "", flags: str = "", coverage: bool = False):
25222557
"""_summary_
25232558
25242559
Args:

0 commit comments

Comments
 (0)