Skip to content

GenModule

1 min read

Import: import system.codegen;

GenModule

A user module whose module declaration carries one of the generator's trigger attributes. Module attributes hold settings that apply to every declaration in the module; combine them with per-declaration attributes through GenContext.module_of.

public class GenModule

id

Stable identifier of the module (module:<path>). Pass it to GenContext.error_at to report a diagnostic at the module declaration.

public id: string

name

Dotted module path, for example shaders.lighting.

public name: string

file

Project-relative path of the file whose module declaration carries the first trigger attribute.

public file: string

location

Location of that module declaration.

public location: GenLocation

attributes

Attributes on the module's declarations, in file order. When several files declare the same module, their attributes are combined.

public attributes: List<GenAttribute>

constructor

Creates a GenModule from its parts. Generators normally receive these from GenContext rather than constructing them.

public constructor(
    id: string,
    name: string,
    file: string,
    location: GenLocation,
    attributes: List<GenAttribute>
)

attribute

Decodes the first attribute of type A on the module, or None when it has none.

public fun attribute<A>(): Option<A>

attributes_of

Decodes every attribute of type A on the module, in source order.

public fun attributes_of<A>(): List<A>

has

Returns whether the module carries an attribute of type A.

public fun has<A>(): bool