# Display a warning
meth warning(s: String)
do
- if not _opt_warn.value then return
+ if _opt_warn.value == 0 then return
stderr.write("{s}\n")
- _warning_count = _warning_count + 1
+ if _opt_warn.value == 1 then
+ _warning_count = _warning_count + 1
+ else
+ _error_count = _error_count + 1
+ end
end
# Paths where to locate modules files
- readable attr _paths: Array[String]
+ readable attr _paths: Array[String] = new Array[String]
# List of module loaders
attr _loaders: Array[ModuleLoader] = new Array[ModuleLoader]
readable attr _option_context: OptionContext = new OptionContext
# Option --warn
- readable attr _opt_warn: OptionBool = new OptionBool("Show warnings", "-W", "--warn")
+ readable attr _opt_warn: OptionCount = new OptionCount("Show warnings", "-W", "--warn")
# Option --path
readable attr _opt_path: OptionArray = new OptionArray("Set include path for loaders (may be used more than once)", "-I", "--path")
option_context.parse(args)
# Setup the paths value
- _paths = new Array[String]
paths.append(opt_path.value)
var path_env = once ("NIT_PATH".to_symbol).environ
# Load and process a module in a directory (or a parent directory).
# If the module is already loaded, just return it without further processing.
# If no module is found, just return null without complaining.
- private meth try_to_load(module_name: Symbol, dir: MMDirectory): MMModule
+ private meth try_to_load(module_name: Symbol, dir: MMDirectory): nullable MMModule
do
# Look in the module directory
for m in dir.modules do
# Locate, load and analysis a module (and its supermodules).
# If the module is already loaded, just return it without further processing.
- meth get_module(module_name: Symbol, from: MMModule): MMModule
+ meth get_module(module_name: Symbol, from: nullable MMModule): MMModule
do
var m: MMModule
if from != null then
- var dir = from.directory
+ var dir: nullable MMDirectory = from.directory
while dir != null do
var m = try_to_load(module_name, dir)
if m != null then return m
meth file_type: String is abstract
# Try to load a new module directory
- meth try_to_load_dir(dirname: Symbol, parent_dir: MMDirectory): MMDirectory
+ meth try_to_load_dir(dirname: Symbol, parent_dir: MMDirectory): nullable MMDirectory
do
var fname = "{parent_dir.path}/{dirname}/"
if not fname.file_exists then return null
abort
end
var m = parse_file(context, file, filename, module_name, dir)
- m.filename = filename
if file != stdin then file.close
return m
end
end
redef class MMModule
- # The filename of the module
- readable writable attr _filename: String
-
- # Last modification time
- readable writable attr _mtime: Int
-
# Recurcivelty process an import modules
meth import_supers_modules(names: Collection[Symbol])
do