예제 #1
0
def hide_code_with_string(obj):
    code = Utils.get_string_from_obj(obj)
    code = Utils.standar_quotes(code)
    obj = Utils.get_obj_from_code(code)
    s_var = g.variable()
    res = "Local " + s_var + ' = "' + obj[0] + '" & _ \n'
    for i in xrange(1, len(obj) - 1):
        res += '"' + obj[i] + '" & _ \n'
    res += '"' + obj[len(obj) - 1] + '"\n'
    res += "Local " + g.variable() + " = Execute(" + s_var + ")\n"
    return res
def add_hardcoded_funcs(obj,add_calls=False,functions=Globals.defined_new_functions,arity=Globals.arity_new_functions,n_funcs_min=3,n_funcs_max=5):
    n_funcs = randint(min(n_funcs_min,n_funcs_max),max(n_funcs_min,n_funcs_max))
    shuffle(hp.HARDCODED_PROGRAMS)
    funcs   = hp.HARDCODED_PROGRAMS[:n_funcs]
    for i in xrange(n_funcs):
	function_code   = funcs[i]()
	obj.insert(0,function_code+"\n\n")
	if add_calls:
	    arity           = Globals.arity_new_functions[-1]
	    identifier      = Globals.defined_new_functions[-1]
	    params          = ",".join([g.value() for i in xrange(arity)])
	    obj.insert(0,Utils.low_up_string(Utils.generate_random_declarator()) + \
		       g.variable() + " = " + identifier + "("+params+")\n\n")
    return obj
예제 #3
0
def add_user_function(obj,
                      pos,
                      arity_min=1,
                      arity_max=4,
                      identifiers_length_min=5,
                      identifiers_length_max=10,
                      n_statements_min=10,
                      n_statements_max=20,
                      n_guard_statements_min=1,
                      n_guard_statements_max=5,
                      n_else_if_min=1,
                      n_else_if_max=5,
                      deep_max=5,
                      case_values_min=-1000,
                      case_values_max=1000):
    obj.insert(
        pos,
        g.block_func(arity_min, arity_max, identifiers_length_min,
                     identifiers_length_max, n_statements_min,
                     n_statements_max, n_guard_statements_min,
                     n_guard_statements_max, n_else_if_min, n_else_if_max,
                     deep_max, case_values_min, case_values_max))
    Globals.defined_new_functions.append(
        obj[pos][obj[pos].find(" "):obj[pos].find("(")])
    return obj
예제 #4
0
def add_function_calls(obj,
                       functions=Globals.defined_new_functions,
                       arity=Globals.arity_new_functions):
    for i in xrange(len(functions)):
        param_names = [g.value() for j in xrange(arity[i])]
        random_pos = choice([0, -1])
        obj.insert(random_pos,
                   functions[i] + "(" + ",".join(param_names) + ")\n\n")
    return obj
예제 #5
0
def add_block(obj,
              pos,
              n_statements_min=10,
              n_statements_max=20,
              n_guard_statements_min=1,
              n_guard_statements_max=5,
              n_else_if_min=1,
              n_else_if_max=5,
              deep_max=5,
              case_values_min=-1000,
              case_values_max=1000):
    obj.insert(
        pos,
        g.block(0, n_statements_min, n_statements_max, n_guard_statements_min,
                n_guard_statements_max, n_else_if_min, n_else_if_max, deep_max,
                case_values_min, case_values_max))
    return obj
예제 #6
0
def add_function_calls(obj,functions=Globals.defined_new_functions,arity=Globals.arity_new_functions):
    for i in xrange(len(functions)):
	param_names = [g.value() for j in xrange(arity[i])]
	random_pos  = choice([0,-1])
	obj.insert(random_pos,functions[i]+"("+",".join(param_names)+")\n\n")
    return obj
예제 #7
0
def add_user_function(obj,pos,arity_min=1,arity_max=4,identifiers_length_min=5,identifiers_length_max=10,n_statements_min=10,n_statements_max=20,n_guard_statements_min=1,n_guard_statements_max=5,n_else_if_min=1,n_else_if_max=5,deep_max=5,case_values_min=-1000,case_values_max=1000):
    obj.insert(pos,g.block_func(arity_min,arity_max,identifiers_length_min,identifiers_length_max,n_statements_min,n_statements_max,n_guard_statements_min,n_guard_statements_max,n_else_if_min,n_else_if_max,deep_max,case_values_min,case_values_max))
    Globals.defined_new_functions.append(obj[pos][obj[pos].find(" "):obj[pos].find("(")])
    return obj
예제 #8
0
def add_block(obj,pos,n_statements_min=10,n_statements_max=20,n_guard_statements_min=1,n_guard_statements_max=5,n_else_if_min=1,n_else_if_max=5,deep_max=5,case_values_min=-1000,case_values_max=1000):
    obj.insert(pos,g.block(0,n_statements_min,n_statements_max,n_guard_statements_min,n_guard_statements_max,n_else_if_min,n_else_if_max,deep_max,case_values_min,case_values_max))
    return obj