Operator declaration#

Signature#

Operator interface declaration, found in module interface.

class ansys.scadeone.core.swan.Signature(id: Identifier, has_inline: bool, is_node: bool, inputs: List[Variable], outputs: List[Variable], sizes: List[Identifier] | None = None, constraints: List[TypeConstraint] | None = None, specialization: PathIdentifier | None = None, pragmas: List[Pragma] | None = None)#

Bases: Declaration, ModuleItem

Operator signature, without a body.

Used in interfaces.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

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

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property constraints: Generator[TypeConstraint, None, None]#

Return constraints as a generator.

property has_inline: bool#

True when operator is marked for inlining.

property id: Identifier#

Language item identifier.

property inputs: Generator[Variable, None, None]#

Returns inputs as a generator.

property is_node: bool#

True when operator is a node.

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property outputs: Generator[Variable, None, None]#

Return outputs as a generator.

property owner: Self#

Owner of current Swan construct.

property pragmas: Generator[Pragma, None, None]#

Return pragmas as a generator.

property sizes: Generator[Identifier, None, None]#

Return sizes as a generator.

property specialization: PathIdentifier | None#

Return specialization path_id or None.

Operator#

Operator definition, found in module body.

class ansys.scadeone.core.swan.Operator(id: Identifier, has_inline: bool, is_node: bool, inputs: List[Variable], outputs: List[Variable], body: Scope | Equation | None | Callable, sizes: List[Identifier] | None = None, constraints: List[TypeConstraint] | None = None, specialization: PathIdentifier | None = None, pragmas: List[Pragma] | None = None)#

Bases: Signature

Operator definition, with a body.

Used in modules. The body may not bet yet defined.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

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

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property body: Scope | Equation | None#

Operator body: a scope, an equation, or None.

property constraints: Generator[TypeConstraint, None, None]#

Return constraints as a generator.

property diagrams: Generator[Diagram, None, None]#

Return a generator on diagram declarations.

property has_body: bool#

True when operator has a body.

property has_inline: bool#

True when operator is marked for inlining.

property id: Identifier#

Language item identifier.

property inputs: Generator[Variable, None, None]#

Returns inputs as a generator.

property is_equation_body: bool#

True when body is reduced to a single equation.

property is_node: bool#

True when operator is a node.

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_text: bool#

True when operator is given from {text%…%text} markup.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property outputs: Generator[Variable, None, None]#

Return outputs as a generator.

property owner: Self#

Owner of current Swan construct.

property pragmas: Generator[Pragma, None, None]#

Return pragmas as a generator.

property signature: Signature#

Return operator signature.

property sizes: Generator[Identifier, None, None]#

Return sizes as a generator.

property specialization: PathIdentifier | None#

Return specialization path_id or None.

Constraints#

Constraint that can be applied to generic types.

class ansys.scadeone.core.swan.TypeConstraint(type_vars: List[VariableTypeExpression] | str, kind: NumericKind)#

Bases: SwanItem

Type constraint for operator. A constraint is:

where_decl ::= where typevar {{ , typevar }} numeric_kind

The typevar list can be protected and represented with string.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

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

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_protected: bool#

True when types are protected.

property kind: NumericKind#

Constraint numeric kind.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property type_vars: List[VariableTypeExpression] | str#

Returns type variable names of constraints.

Returns:
Union[List[VariableTypeExpression], str]

Returns the list of type names, if not protected, or the constraint names as a string.

class ansys.scadeone.core.swan.NumericKind(value)#

Bases: Enum

Numeric kinds for generic type constraints.

Float = 5#

float

Integer = 2#

integer

Numeric = 1#

numeric

Signed = 3#

signed

Unsigned = 4#

unsigned

Scopes#

Scope contains scope sections which define variables, equations, diagrams and other sections.

class ansys.scadeone.core.swan.Scope(sections: List[ScopeSection], pragmas: List[Pragma] | None = None)#

Bases: SwanItem, PragmaBase

Scope definition:

data_def ::= scope
scope ::= { {{scope_section}} }
get_declaration(name: str)#

Returns the type, global, operator or variable declaration searching by namespace.

get_full_path() str#

Full path of Swan construct.

pragma_str() str#

Return a string with all pragmas.

static set_owner(owner: Self, children: Self | Iterable[Self])#

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

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.

property sections: List[ScopeSection]#

Scope sections.

class ansys.scadeone.core.swan.ScopeSection#

Bases: SwanItem

Base class for scopes.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

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

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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_text: bool#

True when section is given from {text%…%text} markup.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.ProtectedSection(data: str)#

Bases: ScopeSection, ProtectedItem

Protected section, meaning a syntactically incorrect section construct.

get_full_path() str#

Full path of Swan construct.

has_markup(markup: str) bool#

Check if protected data has the specified markup.

Parameters:
markupstr

String markup.

Returns:
result: bool

True when instance markup is same as parameter.

static set_owner(owner: Self, children: Self | Iterable[Self])#

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

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

classmethod to_str(section: str, items: List[Any], end: str | None = ';') str#

Print section name with its list of items, one per line, ended with sep string.

property data: str#

Protected data between markups.

Returns:
str

Protected data.

property is_protected#

Tell if item is syntactically protected and provided as a string.

property is_text: bool#

True when section is given from {text%…%text} markup.

property markup: str#

Protection markup.

Returns:
str

Markup string.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.