Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constants - FunctionBlock instances cannot be declared in CONSTANT blocks #295

Closed
Tracked by #208
riederm opened this issue Sep 21, 2021 · 0 comments · Fixed by #306
Closed
Tracked by #208

Constants - FunctionBlock instances cannot be declared in CONSTANT blocks #295

riederm opened this issue Sep 21, 2021 · 0 comments · Fixed by #306
Assignees
Milestone

Comments

@riederm
Copy link
Collaborator

riederm commented Sep 21, 2021

see chapter 6.5.2.1 of the norm

@riederm riederm mentioned this issue Sep 21, 2021
9 tasks
@riederm riederm changed the title CONSTANTS - FunctionBlock instances cannot be declared in CONSTANT blocks Constants - FunctionBlock instances cannot be declared in CONSTANT blocks Sep 22, 2021
riederm added a commit that referenced this issue Sep 26, 2021
fb-instances and class-instances cannot be declared
as constants.

the implementation does not allow to declare a const
of type FB or Class, an array of FBs or Classes
or a struct that contains a field of type FB or
Class.

Furthermore the DataTypeInformation::Struct now contains
a new field: 'source' that indicates where this struct
comes from. It is either an original Declaration
(TYPE x : STRUCT ... END_TYPE) or it was generated
from a POU(PouType). With this field it is now very
easy to see what a DataType offers (is it an FB or Class,
can I call it, etc.)

closes #295
@riederm riederm self-assigned this Sep 26, 2021
@riederm riederm added this to the oscat milestone Sep 26, 2021
riederm added a commit that referenced this issue Sep 27, 2021
…ressions #292) (#306)

* validate illegal fb and class consts

fb-instances and class-instances cannot be declared
as constants.

the implementation does not allow to declare a const
of type FB or Class, an array of FBs or Classes
or a struct that contains a field of type FB or
Class.

Furthermore the DataTypeInformation::Struct now contains
a new field: 'source' that indicates where this struct
comes from. It is either an original Declaration
(TYPE x : STRUCT ... END_TYPE) or it was generated
from a POU(PouType). With this field it is now very
easy to see what a DataType offers (is it an FB or Class,
can I call it, etc.)

closes #295

* add scope to unresolved const expressions

the additional scope parameter in const_evaluator::evaluate(...)
helps the evaluator to distinguish between global constants and
POU-local ones. When resolving const expressions the given
scope will be used to resolve references.

therefore every ConstExpression holds an optional scope when it
is registered (see enum ConstExpression).

closes #292
@ghaith ghaith moved this to Done in Next Jan 9, 2023
@ghaith ghaith added this to Next Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant