<commit_before>
from pycket                 import values
from pycket                 import values_parameter
from pycket                 import vector
from pycket.argument_parser import ArgParser
from pycket.arity           import Arity
from pycket.base            import W_Object
from pycket.error           import SchemeException
from pycket.prims.expose    import expose, expose_val, default, procedure, make_procedure
from rpython.rlib           import jit

@expose("reparameterize")
def reparameterize(args):
    return values.w_void

@expose("make-parameter",
        [values.W_Object, default(values.W_Object, values.w_false)])
def make_parameter(init, guard):
    return values_parameter.W_Parameter(init, guard)

@expose("make-derived-parameter",
        [values_parameter.W_BaseParameter, procedure, procedure])
def make_derived_parameter(param, guard, wrap):
    return values_parameter.W_DerivedParameter(param, guard, wrap)

@expose("extend-parameterization", arity=Arity.geq(1))
@jit.unroll_safe
def scheme_extend_parameterization(args):
    if len(args) == 0:
        raise SchemeException("extend-parameterization: expected 1 or more arguments")

    config = args[0]
    argc = len(args)

    if argc < 2 or argc % 2 != 1: # or not isinstance(config, values_parameter.W_Parameterization):
        return config

    parser = ArgParser("extend-parameterization", args, start_at=1)
    while parser.has_more():
        param  = parser.expect(values_parameter.W_BaseParameter)
        key    = parser.expect(values.W_Object)
        config = config.extend([param], [key])

    return config

def call_with_parameterization(f, args, paramz, env, cont):
    cont.update_cm(values.parameterization_key, paramz)
    return f.call(args, env, cont)

@expose("call-with-parameterization",
        [values.W_Object, values_parameter.W_Parameterization], simple=False)
def call_w_paramz(f, paramz, env, cont):
    return call_with_parameterization(f, [], paramz, env, cont)

def call_with_extended_paramz(f, args, keys, vals, env, cont):
    from pycket.values import parameterization_key
    # XXX seems untested?
    paramz = cont.get_mark_first(parameterization_key)
    assert isinstance(paramz, values_parameter.W_Parameterization) # XXX is this always right?
    paramz_new = paramz.extend(keys, vals)
    return call_with_parameterization(f, args, paramz_new, env, cont)

@make_procedure("eval-jit-enabled-guard", [values.W_Object], simple=False)
def eval_jit_enabled_guard(arg, env, cont):
    from pycket.interpreter import return_value
    # never disable the jit
    return return_value(values.w_void, env, cont)

expose_val("compile-enforce-module-constants", values_parameter.W_Parameter(values.w_true))

# compilation should avoid function-call inlining and other optimizations that may cause information to be lost from stack traces
expose_val("compile-context-preservation-enabled", values_parameter.W_Parameter(values.w_true))

expose_val("compile-allow-set!-undefined", values_parameter.W_Parameter(values.w_false))

current_cmd_args_param = values_parameter.W_Parameter(vector.W_Vector.fromelements([]))
expose_val("current-command-line-arguments", current_cmd_args_param)
expose_val("eval-jit-enabled", values_parameter.W_Parameter(values.w_true, eval_jit_enabled_guard))
expose_val("exnh", values_parameter.W_Parameter(values.w_false))
expose_val("load-on-demand-enabled", values_parameter.W_Parameter(values.w_true))
expose_val("read-on-demand-source", values_parameter.W_Parameter(values.w_true))
expose_val("parameterization-key", values.parameterization_key)
expose_val("print-mpair-curly-braces", values_parameter.W_Parameter(values.w_false))<commit_msg>fixing the argument order in call-with-parameterization<commit_after>
from pycket                 import values
from pycket                 import values_parameter
from pycket                 import vector
from pycket.argument_parser import ArgParser
from pycket.arity           import Arity
from pycket.base            import W_Object
from pycket.error           import SchemeException
from pycket.prims.expose    import expose, expose_val, default, procedure, make_procedure
from rpython.rlib           import jit

@expose("reparameterize")
def reparameterize(args):
    return values.w_void

@expose("make-parameter",
        [values.W_Object, default(values.W_Object, values.w_false)])
def make_parameter(init, guard):
    return values_parameter.W_Parameter(init, guard)

@expose("make-derived-parameter",
        [values_parameter.W_BaseParameter, procedure, procedure])
def make_derived_parameter(param, guard, wrap):
    return values_parameter.W_DerivedParameter(param, guard, wrap)

@expose("extend-parameterization", arity=Arity.geq(1))
@jit.unroll_safe
def scheme_extend_parameterization(args):
    if len(args) == 0:
        raise SchemeException("extend-parameterization: expected 1 or more arguments")

    config = args[0]
    argc = len(args)

    if argc < 2 or argc % 2 != 1: # or not isinstance(config, values_parameter.W_Parameterization):
        return config

    parser = ArgParser("extend-parameterization", args, start_at=1)
    while parser.has_more():
        param  = parser.expect(values_parameter.W_BaseParameter)
        key    = parser.expect(values.W_Object)
        config = config.extend([param], [key])

    return config

def call_with_parameterization(f, args, paramz, env, cont):
    cont.update_cm(values.parameterization_key, paramz)
    return f.call(args, env, cont)

@expose("call-with-parameterization",
        [values_parameter.W_Parameterization, values.W_Object], simple=False)
def call_w_paramz(paramz, f, env, cont):
    return call_with_parameterization(f, [], paramz, env, cont)

def call_with_extended_paramz(f, args, keys, vals, env, cont):
    from pycket.values import parameterization_key
    # XXX seems untested?
    paramz = cont.get_mark_first(parameterization_key)
    assert isinstance(paramz, values_parameter.W_Parameterization) # XXX is this always right?
    paramz_new = paramz.extend(keys, vals)
    return call_with_parameterization(f, args, paramz_new, env, cont)

@make_procedure("eval-jit-enabled-guard", [values.W_Object], simple=False)
def eval_jit_enabled_guard(arg, env, cont):
    from pycket.interpreter import return_value
    # never disable the jit
    return return_value(values.w_void, env, cont)

expose_val("compile-enforce-module-constants", values_parameter.W_Parameter(values.w_true))

# compilation should avoid function-call inlining and other optimizations that may cause information to be lost from stack traces
expose_val("compile-context-preservation-enabled", values_parameter.W_Parameter(values.w_true))

expose_val("compile-allow-set!-undefined", values_parameter.W_Parameter(values.w_false))

current_cmd_args_param = values_parameter.W_Parameter(vector.W_Vector.fromelements([]))
expose_val("current-command-line-arguments", current_cmd_args_param)
expose_val("eval-jit-enabled", values_parameter.W_Parameter(values.w_true, eval_jit_enabled_guard))
expose_val("exnh", values_parameter.W_Parameter(values.w_false))
expose_val("load-on-demand-enabled", values_parameter.W_Parameter(values.w_true))
expose_val("read-on-demand-source", values_parameter.W_Parameter(values.w_true))
expose_val("parameterization-key", values.parameterization_key)
expose_val("print-mpair-curly-braces", values_parameter.W_Parameter(values.w_false))
{'fraction_non_alphanumeric': 0.10035068788777987, 'fraction_numerical': 0.002158079309414621, 'mean_word_length': 5.067921440261866, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1042884', 'n_tokens_mistral': 2294, 'n_tokens_neox': 2239, 'n_words': 472}