예제 #1
0
def load_bootstrap_linklet(which_str,
                           debug,
                           is_it_expander=False,
                           from_fasl=True):
    from pycket.error import SchemeException

    with PerfRegion("%s-linklet" % which_str):
        console_log("Loading the %s linklet..." % which_str)
        linklet_file_path = locate_linklet("%s.rktl.linklet" % which_str)
        if from_fasl:
            try:
                linklet_file_path = locate_linklet("%s.zo" % which_str)
            except SchemeException:
                linklet_file_path = locate_linklet("%s.fasl" % which_str)

        # load the linklet
        _instance = load_inst_linklet(linklet_file_path,
                                      debug,
                                      set_version=is_it_expander,
                                      from_fasl=from_fasl)
        _instance.expose_vars_to_prim_env(excludes=syntax_primitives)

        if is_it_expander:
            from pycket.env import w_global_config
            w_global_config.set_config_val('expander_loaded', 1)

        return 0
예제 #2
0
def pytest_configure(config):
    if config.getvalue('random'):
        from rpython.rlib import jit
        jit.isconstant = replace(jit.isconstant)
        jit.isvirtual = replace(jit.isvirtual)
        # XXX: Being able to patch we_are_jitted would be nice as well,
        # but too much code depends on it behaving deterministically

    from pycket.env import w_global_config

    config.byte_option = False
    config.new_pycket = False
    config.load_expander = False

    if config.getvalue('--new'):
        print("\nTesting with NEW Pycket... ")
        config.new_pycket = True
        if config.getvalue('--use-expander'):
            print("using the expander linklet...\n")
            w_global_config.set_config_val('expander_loaded', 1)
            config.load_expander = True
        else:
            print("WITHOUT using the expander linklet...\n")
    else:
        print("\nTesting with OLD Pycket... ")
        w_global_config.set_linklet_mode_off()
예제 #3
0
    def actual_entry(argv):
        jit.set_param(None, "trace_limit", 1000000)
        jit.set_param(None, "threshold", 131)
        jit.set_param(None, "trace_eagerness", 50)
        jit.set_param(None, "max_unroll_loops", 15)

        from pycket.env import w_global_config
        w_global_config.set_pycketconfig(pycketconfig)

        config, names, args, retval = parse_args(argv)

        if config['verbose']:
            level = int(names['verbosity_level'][0])
            w_global_config.set_config_val('verbose', level)

            if 'verbosity_keywords' in names:
                w_global_config.set_verbose_keywords(
                    names['verbosity_keywords'])

            if 'not-implemented' in names:
                print("These flags are not implemented yet : %s" %
                      names['not-implemented'])

        if retval == MISSING_ARG:
            print("Bad switch, or missing argument in : %s" % argv[1:])
            return 1

        if retval == JUST_EXIT or config is None:
            return RETURN_OK  # exit normally

        if 'stdout_level' in names:  # -O
            from pycket.prims.logging import w_main_logger
            w_main_logger.set_stdout_level(names['stdout_level'][0])

        if 'stderr_level' in names:  # -W
            from pycket.prims.logging import w_main_logger
            w_main_logger.set_stderr_level(names['stderr_level'][0])

        if 'syslog_level' in names:  # -L
            from pycket.prims.logging import w_main_logger
            w_main_logger.set_syslog_level(names['syslog_level'][0])

        current_cmd_args = [W_String.fromstr_utf8(arg) for arg in args]

        if 'json-linklets' in names:
            for linkl_json in names['json-linklets']:
                vvv = config['verbose']
                load_inst_linklet(linkl_json, debug=vvv)

        try:
            if not config['stop']:
                racket_entry(names, config, current_cmd_args)
        except ExitException, e:
            pass
예제 #4
0
def load_bootstrap_linklet(which_str, debug, is_it_expander=False, generate_zo=False):
    with PerfRegion("%s-linklet" % which_str):
        console_log("Loading the %s linklet..." % which_str)
        linklet_file_path = locate_linklet("%s.rktl.linklet" % which_str)

        # load the linklet
        _instance, sys_config = load_inst_linklet_json(linklet_file_path, debug, set_version=is_it_expander, generate_zo=generate_zo)
        _instance.expose_vars_to_prim_env(excludes=syntax_primitives)

        if is_it_expander:
            from pycket.env import w_global_config
            w_global_config.set_config_val('expander_loaded', 1)

        return sys_config
예제 #5
0
delete_temp_files = True

##############################
## NEW Pycket test helpers
##############################

instantiate_linklet = get_primitive("instantiate-linklet")

# This is where all the work happens

try:
    if not pytest.config.new_pycket:
        w_global_config.set_linklet_mode_off()

    if pytest.config.load_expander:
        w_global_config.set_config_val('expander_loaded', 1)
        # get the expander
        print("Loading and initializing the expander")
        initiate_boot_sequence([], False)
        # load the '#%kernel
        print("(namespace-require '#%%kernel)")
        namespace_require_kernel()
except:
    pass


def run_sexp(body_sexp_str,
             v=None,
             just_return=False,
             extra="",
             equal_huh=False,
예제 #6
0
def racket_entry(names, config, command_line_arguments):
    from pycket.prims.general import executable_yield_handler
    from pycket.values import W_Fixnum

    if config['make-zos']:
        make_bootstrap_zos()
        return 0

    linklet_perf.init()

    loads, startup_options, flags = get_options(names, config)

    init_library     = startup_options['init_library'][0]
    set_run_file     = startup_options['set_run_file'][0]
    set_collects_dir = startup_options['set_collects_dir'][0]
    set_config_dir   = startup_options['set_config_dir'][0]
    set_addon_dir    = startup_options['set_addon_dir'][0]
    eval_sexp        = startup_options['eval_sexp'][0]
    run_as_linklet   = startup_options['run_as_linklet'][0]
    load_linklets    = startup_options['load_linklets']
    load_as_linklets = startup_options['load_as_linklets']

    is_repl          = flags['is_repl']
    no_lib           = flags['no_lib']
    just_kernel      = flags['just_kernel']
    just_init        = flags['just_init']
    use_compiled     = flags['use_compiled']
    debug            = flags['debug']
    version          = flags['version']
    c_a              = flags['compile_any']
    do_load_regexp   = flags['do_load_regexp']
    dev_mode         = flags['dev_mode']

    if load_as_linklets:
        for rkt in load_as_linklets:
            create_linklet_json(rkt)
            load_inst_linklet("%s.linklet" % rkt)
        return 0

    if load_linklets:
        load_linklets_at_startup(load_linklets)
        return 0

    if dev_mode:
        dev_mode_entry(dev_mode, eval_sexp, run_as_linklet)
        return 0

    with PerfRegion("startup"):
        initiate_boot_sequence(command_line_arguments,
                               use_compiled,
                               debug,
                               set_run_file,
                               set_collects_dir,
                               set_config_dir,
                               set_addon_dir,
                               compile_any=c_a,
                               do_load_regexp=do_load_regexp)

    if just_init:
        return 0

    namespace_require = get_primitive("namespace-require")
    load = get_primitive("load")

    if just_kernel:
        console_log("Running on just the #%kernel")
        namespace_require_kernel()

    if not no_lib:
        with PerfRegion("init-lib"):
            init_lib = W_WrappedConsProper.make(W_Symbol.make("lib"),
                                                W_WrappedConsProper.make(W_String.make(init_library), w_null))
            console_log("(namespace-require %s) ..." % init_lib.tostring())

            namespace_require_plus(init_lib)
            console_log("Init lib : %s loaded..." % (init_library))

    put_newline = False
    if loads:
        for rator_str, rand_str in loads:
            if rator_str == "load":
                # -f
                console_log("(load %s)" % (rand_str))
                load.call_interpret([W_String.make(rand_str)])
            elif rator_str == "file" or rator_str == "lib":
                # -t & -l
                require_spec = W_WrappedConsProper.make(W_Symbol.make(rator_str),
                                                        W_WrappedConsProper.make(W_String.make(rand_str), w_null))
                console_log("(namespace-require '(%s %s))" % (rator_str, rand_str))
                namespace_require_plus(require_spec)
            elif rator_str == "eval":
                # -e
                console_log("(eval (read (open-input-string %s)))" % rand_str)
                read_eval_print_string(rand_str, False, debug)

    if version:
        from pycket.env import w_version
        print("Welcome to Pycket v%s" % w_version.get_version())

    if is_repl: # -i
        put_newline = True
        dynamic_require = get_primitive("dynamic-require")
        repl = dynamic_require.call_interpret([W_Symbol.make("racket/repl"),
                                               W_Symbol.make("read-eval-print-loop")])
        from pycket.env import w_global_config
        w_global_config.set_config_val('repl_loaded', 1)
        repl.call_interpret([])

    if put_newline:
        print


    linklet_perf.print_report()

    # we just want the global value anyway
    eyh = executable_yield_handler.call_interpret([])
    eyh.call_interpret([W_Fixnum.ZERO])

    exit = get_primitive("exit")
    exit.call_interpret([])

    return 0