src/basilisp/importer.py
def _exec_module(
        self,
        fullname: str,
        loader_state: Mapping[str, str],
        path_stats: Mapping[str, int],
        module: types.ModuleType,
    ):
        """Load and execute a non-cached Basilisp module."""
        filename = loader_state["filename"]
        cache_filename = loader_state["cache_filename"]

        with timed(
            lambda duration: logger.debug(
                f"Loaded Basilisp module '{fullname}' in {duration / 1000000}ms"
            )
        ):
            # During compilation, bytecode objects are added to the list via the closure
            # add_bytecode below, which is passed to the compiler. The collected bytecodes
            # will be used to generate an .lpyc file for caching the compiled file.
            all_bytecode = []

            def add_bytecode(bytecode: types.CodeType):
                all_bytecode.append(bytecode)

            logger.debug(f"Reading and compiling Basilisp module '{fullname}'")
            forms = reader.read_file(filename, resolver=runtime.resolve_alias)
            compiler.compile_module(  # pylint: disable=unexpected-keyword-arg
                forms,
                compiler.CompilerContext(filename=filename),
                module,
                collect_bytecode=add_bytecode,
            )

        # Cache the bytecode that was collected through the compilation run.
        cache_file_bytes = _basilisp_bytecode(
            path_stats["mtime"], path_stats["size"], all_bytecode
        )
        self._cache_bytecode(filename, cache_filename, cache_file_bytes)
def _exec_module(
        self,
        fullname: str,
        loader_state: Mapping[str, str],
        path_stats: Mapping[str, int],
        module: types.ModuleType,
    ):
        filename = loader_state["filename"]
        cache_filename = loader_state["cache_filename"]

        with timed(
            lambda duration: logger.debug(
                f"Loaded Basilisp module '{fullname}' in {duration / 1000000}ms"
            )
        ):
            # During compilation, bytecode objects are added to the list via the closure
            # add_bytecode below, which is passed to the compiler. The collected bytecodes
            # will be used to generate an .lpyc file for caching the compiled file.
            all_bytecode = []

            def add_bytecode(bytecode: types.CodeType):
                all_bytecode.append(bytecode)

            logger.debug(f"Reading and compiling Basilisp module '{fullname}'")
            forms = reader.read_file(filename, resolver=runtime.resolve_alias)
            compiler.compile_module(  # pylint: disable=unexpected-keyword-arg
                forms,
                compiler.CompilerContext(filename=filename),
                module,
                collect_bytecode=add_bytecode,
            )

        # Cache the bytecode that was collected through the compilation run.
        cache_file_bytes = _basilisp_bytecode(
            path_stats["mtime"], path_stats["size"], all_bytecode
        )
        self._cache_bytecode(filename, cache_filename, cache_file_bytes)
def _exec_module ( self , fullname : str , loader_state : Mapping [ str , str ] , path_stats : Mapping [ str , int ] , module : types . ModuleType , ) : filename = loader_state [ "filename" ] cache_filename = loader_state [ "cache_filename" ] with timed ( lambda duration : logger . debug ( f"Loaded Basilisp module '{fullname}' in {duration / 1000000}ms" ) ) : # During compilation, bytecode objects are added to the list via the closure # add_bytecode below, which is passed to the compiler. The collected bytecodes # will be used to generate an .lpyc file for caching the compiled file. all_bytecode = [ ] def add_bytecode ( bytecode : types . CodeType ) : all_bytecode . append ( bytecode ) logger . debug ( f"Reading and compiling Basilisp module '{fullname}'" ) forms = reader . read_file ( filename , resolver = runtime . resolve_alias ) compiler . compile_module ( # pylint: disable=unexpected-keyword-arg forms , compiler . CompilerContext ( filename = filename ) , module , collect_bytecode = add_bytecode , ) # Cache the bytecode that was collected through the compilation run. cache_file_bytes = _basilisp_bytecode ( path_stats [ "mtime" ] , path_stats [ "size" ] , all_bytecode ) self . _cache_bytecode ( filename , cache_filename , cache_file_bytes )
Load and execute a non-cached Basilisp module.
Load and execute a non - cached Basilisp module .