src/basilisp/lang/compiler/__init__.py
def compile_and_exec_form(  # pylint: disable= too-many-arguments
    form: ReaderForm,
    ctx: CompilerContext,
    module: types.ModuleType,
    wrapped_fn_name: str = _DEFAULT_FN,
    collect_bytecode: Optional[BytecodeCollector] = None,
) -> Any:
    """Compile and execute the given form. This function will be most useful
    for the REPL and testing purposes. Returns the result of the executed expression.

    Callers may override the wrapped function name, which is used by the
    REPL to evaluate the result of an expression and print it back out."""
    if form is None:
        return None

    if not module.__basilisp_bootstrapped__:  # type: ignore
        _bootstrap_module(ctx.generator_context, ctx.py_ast_optimizer, module)

    final_wrapped_name = genname(wrapped_fn_name)

    lisp_ast = parse_ast(ctx.parser_context, form)
    py_ast = gen_py_ast(ctx.generator_context, lisp_ast)
    form_ast = list(
        map(
            _statementize,
            itertools.chain(
                py_ast.dependencies,
                [_expressionize(GeneratedPyAST(node=py_ast.node), final_wrapped_name)],
            ),
        )
    )

    ast_module = ast.Module(body=form_ast)
    ast_module = ctx.py_ast_optimizer.visit(ast_module)
    ast.fix_missing_locations(ast_module)

    _emit_ast_string(ast_module)

    bytecode = compile(ast_module, ctx.filename, "exec")
    if collect_bytecode:
        collect_bytecode(bytecode)
    exec(bytecode, module.__dict__)
    return getattr(module, final_wrapped_name)()
def compile_and_exec_form(  # pylint: disable= too-many-arguments
    form: ReaderForm,
    ctx: CompilerContext,
    module: types.ModuleType,
    wrapped_fn_name: str = _DEFAULT_FN,
    collect_bytecode: Optional[BytecodeCollector] = None,
) -> Any:
    if form is None:
        return None

    if not module.__basilisp_bootstrapped__:  # type: ignore
        _bootstrap_module(ctx.generator_context, ctx.py_ast_optimizer, module)

    final_wrapped_name = genname(wrapped_fn_name)

    lisp_ast = parse_ast(ctx.parser_context, form)
    py_ast = gen_py_ast(ctx.generator_context, lisp_ast)
    form_ast = list(
        map(
            _statementize,
            itertools.chain(
                py_ast.dependencies,
                [_expressionize(GeneratedPyAST(node=py_ast.node), final_wrapped_name)],
            ),
        )
    )

    ast_module = ast.Module(body=form_ast)
    ast_module = ctx.py_ast_optimizer.visit(ast_module)
    ast.fix_missing_locations(ast_module)

    _emit_ast_string(ast_module)

    bytecode = compile(ast_module, ctx.filename, "exec")
    if collect_bytecode:
        collect_bytecode(bytecode)
    exec(bytecode, module.__dict__)
    return getattr(module, final_wrapped_name)()
def compile_and_exec_form ( # pylint: disable= too-many-arguments form : ReaderForm , ctx : CompilerContext , module : types . ModuleType , wrapped_fn_name : str = _DEFAULT_FN , collect_bytecode : Optional [ BytecodeCollector ] = None , ) -> Any : if form is None : return None if not module . __basilisp_bootstrapped__ : # type: ignore _bootstrap_module ( ctx . generator_context , ctx . py_ast_optimizer , module ) final_wrapped_name = genname ( wrapped_fn_name ) lisp_ast = parse_ast ( ctx . parser_context , form ) py_ast = gen_py_ast ( ctx . generator_context , lisp_ast ) form_ast = list ( map ( _statementize , itertools . chain ( py_ast . dependencies , [ _expressionize ( GeneratedPyAST ( node = py_ast . node ) , final_wrapped_name ) ] , ) , ) ) ast_module = ast . Module ( body = form_ast ) ast_module = ctx . py_ast_optimizer . visit ( ast_module ) ast . fix_missing_locations ( ast_module ) _emit_ast_string ( ast_module ) bytecode = compile ( ast_module , ctx . filename , "exec" ) if collect_bytecode : collect_bytecode ( bytecode ) exec ( bytecode , module . __dict__ ) return getattr ( module , final_wrapped_name ) ( )
Compile and execute the given form. This function will be most useful
    for the REPL and testing purposes. Returns the result of the executed expression.

    Callers may override the wrapped function name, which is used by the
    REPL to evaluate the result of an expression and print it back out.
Compile and execute the given form . This function will be most useful for the REPL and testing purposes . Returns the result of the executed expression .