Constant declaration#

class ansys.scadeone.core.swan.ConstDecl(id: Identifier, is_elaborated: bool, type: TypeExpression | None, value: Expression | None = None, pragmas: list[Pragma] | None = None)#

Bases: Declaration

Constant declaration, with an id, a type, and an optional expression.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) → None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

add_pragmas(*pragmas) → None#

Add one or more pragmas to the current object.

get_full_path() → str#

Full path of Swan construct.

property has_definition: bool#

True if constant has a value.

property id: Identifier#

Language item identifier.

property is_elaborated: bool#

True if constant is elaborated.

property is_external: bool#

True if declaration has no definition.

Check if there is no alternative declaration in the module (interface or body). Warn if any, and raise an error if inconsistent.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property is_public: bool#

True if declaration is public.

A declaration is public if:

  • it is declared in a module interface,

  • or it is declared in a module body, but the module has no interface.

A declaration is private if it is declared in a module body, and the module has an interface, and there is no declaration with the same name in the module interface.

If declared in both a module interface and body, the declaration is considered as public, but a warning is issued.

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property type: TypeExpression | None#

Type of constant.

property value: Expression | None#

Constant optional value. None if undefined.

class ansys.scadeone.core.swan.ConstDeclarations(constants: List[ConstDecl])#

Bases: GlobalDeclaration

Constant declarations: constant {{ constant_decl ; }}.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) → None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

get_full_path() → str#

Full path of Swan construct.

property constants: List[ConstDecl]#

Declared constants.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.