# dmd.dmodule

Defines a package and module.

Specification: Modules

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: dmodule.d

Documentation: https://dlang.org/phobos/dmd_dmodule.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/dmodule.d

- `removeHdrFilesAndFail`

  #### Declaration

  `nothrow void `removeHdrFilesAndFail`(ref Param `params`, ref Modules `modules`);`

  Remove generated .di files on error and exit

- `Package`

  #### Declaration

  `class `Package`: dmd.dsymbol.ScopeDsymbol;`

  - `resolve`

    #### Declaration

    `static DsymbolTable `resolve`(Identifier[] `packages`, Dsymbol* `pparent`, Package* `ppkg`);`

    Input: `packages`[] the pkg1.pkg2 of pkg1.pkg2.mod

    #### Return Value

    the symbol table that mod should be inserted into

    Output: *`pparent` the rightmost package, i.e. pkg2, or NULL if no `packages` *`ppkg` the leftmost package, i.e. pkg1, or NULL if no `packages`

  - `isAncestorPackageOf`

    #### Declaration

    `final const bool `isAncestorPackageOf`(const Package `pkg`);`

    Checks if `pkg` is a sub-package of this

    #### Discussion

    For example, if this qualifies to 'a1.a2' and `pkg` - to 'a1.a2.a3', this function returns '`true`'. If it is other way around or qualified package paths conflict function returns '`false`'.

    #### Parameters

    `Package `pkg`` | possible subpackage

    #### Return Value

    see description

  - `resolvePKGunknown`

    #### Declaration

    `final void `resolvePKGunknown`();`

    Checks for the existence of a package.d to set isPkgMod appropriately if isPkgMod == PKG.unknown

- `Module`

  #### Declaration

  `class `Module`: dmd.dmodule.Package;`

  - `deinitialize`

    #### Declaration

    `static void `deinitialize`();`

    Deinitializes the global state of the compiler.

    #### Discussion

    This can be used to restore the state set by `_init` to its original state.

  - `src`

    #### Declaration

    `const(ubyte)[] `src`;`

    Raw content of the file

  - `tagSymTab`

    #### Declaration

    `Dsymbol[void*] `tagSymTab`;`

    ImportC: tag symbols that conflict with other symbols used as the index

  - `selfImports`

    #### Declaration

    `bool `selfImports`();`

    Return `true` if module imports itself.

  - `rootImports`

    #### Declaration

    `bool `rootImports`();`

    Return `true` if module imports root module.

  - `importedFrom`

    #### Declaration

    `Module `importedFrom`;`

    A root module is one that will be compiled all the way to object code. This field holds the root module that caused this module to be loaded. If this module is a root module, then it will be set to `this`. This is used to determine ownership of template instantiation.

  - `setOutfilename`

    #### Declaration

    `FileName `setOutfilename`(const(char)[] `name`, const(char)[] `dir`, const(char)[] `arg`, const(char)[] `ext`);`

    Combines things into output file `name` for .html and .di files.

    Input: `name` Command line `name` given for the file, NULL if none `dir` Command line directory given for the file, NULL if none `arg` Name of the source file `ext` File `name` extension to use if '`name`' is NULL global.params.preservePaths get output path from `arg` srcfile Input file - output file `name` must not match input file

  - `read`

    #### Declaration

    `bool `read`(const ref Loc `loc`);`

    Reads the file from `srcfile` and loads the source buffer.

    #### Discussion

    If makefile module dependency is requested, we add this module to the list of dependencies from here.

    #### Parameters

    `Loc `loc`` | the location

    #### Return Value

    `true` if successful

  - `parse`

    #### Declaration

    `Module `parse`();
    Module `parseModule`(AST)();`

    syntactic `parse`

  - `needModuleInfo`

    #### Declaration

    `int `needModuleInfo`();`

    Determine if we need to generate an instance of ModuleInfo for this Module.

  - `checkImportDeprecation`

    #### Declaration

    `void `checkImportDeprecation`(const ref Loc `loc`, Scope* `sc`);`

    Print deprecation warning if we're deprecated, when this module is imported from scope `sc`.

    #### Parameters

    `Scope* `sc`` | the scope into which we are imported
    `Loc `loc`` | the location of the import statement

  - `addDeferredSemantic`

    #### Declaration

    `static void `addDeferredSemantic`(Dsymbol `s`);`

    Can't run semantic on `s` now, try again later.

  - `runDeferredSemantic`

    #### Declaration

    `static void `runDeferredSemantic`();`

    Run semantic() on deferred symbols.

  - `imports`

    #### Declaration

    `nothrow int `imports`(Module `m`);`

    Recursively look at every module this module `imports`, return `true` if it `imports` `m`. Can be used to detect circular `imports`.

  - `ctfe_cov`

    #### Declaration

    `uint[uint] `ctfe_cov`;`

    coverage information from ctfe execution_count[line]

  - `fullyQualifiedName`

    #### Declaration

    `nothrow void `fullyQualifiedName`(ref OutBuffer `buf`);`

    Writes this module's fully-qualified name to `buf`

    #### Parameters

    `OutBuffer `buf`` | The buffer to write to

  - `escapetable`

    #### Declaration

    `nothrow Escape* `escapetable`();`

    Lazily initializes and returns the escape table. Turns out it eats a lot of memory.

- `ModuleDeclaration`

  #### Declaration

  `struct `ModuleDeclaration`;`

  - `toString`

    #### Declaration

    `const const(char)[] `toString`();`

    Provide a human readable representation