Learn R Programming

SpaDES.core (version 3.2.1)

.reparseModules: Re-parse module source into a simList

Description

Re-parse()s the named modules' source files and evaluates them into the simList's module environments. Shared by three callers, for two different reasons:

Usage

.reparseModules(sim, modules, verbose = getOption("reproducible.verbose"))

Value

sim, invisibly.

Arguments

sim

A simList.

modules

Character vector of (non-core) module names to re-parse.

verbose

Numeric verbosity. At verbose > 0 each re-parsed module is announced; a module whose source cannot be found, or whose code cannot be evaluated (e.g., a package it loads is not installed), always warns.

Details

  • restartSpades() and restartSimInit() use it to pick up any fixes the developer made to a module after an interrupted run;

  • loadSimList() uses it because saveSimList() does not carry the module functions at all. Copy(objects = 2) -- the path .wrap.simList() takes -- rebuilds each .mods[[module]] environment from scratch and copies only .modObjs back into it, so without this a reloaded simList fails with object 'doEvent.<module>' not found.

Only the module's code is evaluated: the defineModule() item is skipped. Its metadata is already in the simList -- and for a loaded simList that metadata is end-state, so re-evaluating defineModule() would risk replacing it with the module's declared defaults. That is exactly why "just call simInit() again" is not an answer for loadSimList().

Operates by side effect on sim@.xData (an environment), so the input sim is mutated in place.