Operator declaration#

Signature#

Operator interface declaration, found in module interface.

class ansys.scadeone.core.swan.Signature(id: Identifier, is_inlined: 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: OperatorSignatureBase, SignatureCreator

Operator interface definition.

Used in module body or interface.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: SwanItem | IProject | None, children: SwanItem | Iterable[SwanItem]) 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]]

Items to set owner.

property constraints: List[TypeConstraint]#

Return constraints as a list.

property id: Identifier#

Language item identifier.

property inputs: List[Variable]#

Return inputs as a list.

property is_inlined: bool#

True when operator is marked for inlining.

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, or an interface is given from {text%…%text} markup (body) or {signature%…%signature} markup (interface).

property model: Model#

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 outputs: List[Variable]#

Return outputs as a list.

property owner: SwanItem | IProject | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

Return pragmas as a list.

property sizes: List[Identifier]#

Return sizes as a list.

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, is_inlined: bool, is_node: bool, inputs: List[Variable], outputs: List[Variable], body: Scope | Equation | Callable | None = None, sizes: List[Identifier] | None = None, constraints: List[TypeConstraint] | None = None, specialization: PathIdentifier | None = None, pragmas: List[Pragma] | None = None)#

Bases: OperatorSignatureBase, OperatorCreator

Operator definition, with a body.

Used in modules. The body may be empty.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: SwanItem | IProject | None, children: SwanItem | Iterable[SwanItem]) 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]]

Items to set owner.

property body: Scope | Equation | None#

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

property constraints: List[TypeConstraint]#

Return constraints as a list.

property diagrams: List[Diagram]#

Return a list of diagram declarations.

property has_body: bool#

True when operator has a body.

property id: Identifier#

Language item identifier.

property inputs: List[Variable]#

Return inputs as a list.

property is_equation_body: bool#

True when body is reduced to a single equation.

property is_inlined: bool#

True when operator is marked for inlining.

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, or an interface is given from {text%…%text} markup (body) or {signature%…%signature} markup (interface).

property model: Model#

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 outputs: List[Variable]#

Return outputs as a list.

property owner: SwanItem | IProject | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

Return pragmas as a list.

property sizes: List[Identifier]#

Return sizes as a list.

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: SwanItem | IProject | None, children: SwanItem | Iterable[SwanItem]) 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]]

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 | 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 | IProject | None#

Owner of current Swan construct.

property type_vars: List[VariableTypeExpression] | str#

Return 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] | None = None, 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.

pragmas_str() str#

Return a string with all pragmas.

static set_owner(owner: SwanItem | IProject | None, children: SwanItem | Iterable[SwanItem]) 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]]

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 | 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 | IProject | None#

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: SwanItem | IProject | None, children: SwanItem | Iterable[SwanItem]) 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]]

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 | 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 | IProject | None#

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: SwanItem | IProject | None, children: SwanItem | Iterable[SwanItem]) 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]]

Items to set owner.

property data: str#

Protected data between markups.

Returns:
str

Protected data.

property is_protected: bool#

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 | 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 | IProject | None#

Owner of current Swan construct.