Ejemplo n.º 1
0
def change_str(program_tree, verbose=0, numbermax=NUMBERMAX):
    if verbose > 1:
        print "apply change_str transformation", "with", numbermax
    p = deepcopy(program_tree)
    ret = get_all_ident(program_tree)
    arg = {"numbermax": numbermax, "ident_present": ret}
    arg["size"] = count_object(p, [String])
    walker(p, postfunction=change_str_func, arg=arg)
    return p
def duplicate_function(program_tree, verbose=0, numbermax=NUMBERMAX):
    if verbose > 1:
        print "apply duplicate_function transformation", "with", numbermax
    p = deepcopy(program_tree)
    ret = get_all_ident(program_tree)
    arg = {"ident_present": ret, "numbermax": numbermax}
    arg["size"] = count_object(p, [Statements])
    walker(p, postfunction=duplicate_function_func_post, arg=arg)
    return p
def modify_data_flow_1(program_tree, verbose=0, numbermax=NUMBERMAX):
    if verbose > 1:
        print "apply modify_data_flow_1 transformation"
    p = deepcopy(program_tree)
    ret = get_all_ident(program_tree)
    arg = {"ident_present":ret, "numbermax":numbermax}
    arg["size"] = count_object(p, [Assignment])
    walker(p, postfunction=modify_data_flow_1_post_func, arg=arg)
    return p
Ejemplo n.º 4
0
def rename_variables(program_tree, verbose=0, numbermax=NUMBERMAX):
    if verbose > 1:
        print "apply rename_variables transformation"
    p = deepcopy(program_tree)
    ret = get_all_ident(program_tree)
    if "eval" in ret:
        return program_tree
    arg = {"idents": ret, "switcher": [], "numbermax": numbermax}
    arg["size"] = count_object(p, [Ident])
    walker(p, rename_variables_func, rename_variables_post_func, arg=arg)
    return p
def add_dummy_variables(parse_tree, verbose=0, numbermax=NUMBERMAX):
    """This function takes in arpument parse_tree as a parse tree, and will add some dummy variables,
    it will return a new parse tree, with these dummy variables
    the verbose argument allows to increase verbosity"""
    if verbose > 1:
        print "apply add_dummy_var transformation"
    p = deepcopy(parse_tree)
    ret = get_all_ident(parse_tree)
    arg = {"ident_present": ret, "numbermax": numbermax}
    arg["size"] = count_object(p, [Statements])
    walker(p, postfunction=add_dummy_var_func_post, arg=arg)
    return p
def aggregate_data(program_tree, verbose=0, numbermax=NUMBERMAX):
    if verbose > 1:
        print "apply aggregate_data transformation"
    p = deepcopy(program_tree)
    ret = get_all_ident(program_tree)
    arg = {
        "ident_present": ret,
        "numbermax": numbermax,
        "list_aggregation": []
    }
    arg["size"] = count_object(p, [Number])
    walker(p, aggregate_data_func, aggregate_data_post_func, arg=arg)
    return p