PLCgen: Reconsider expression + type model classes
Starting point for this issue is comment !785 (comment 1704170) while discussing trouble in handling function blocks, as they allow both variable access and a function call.
The basic trouble is that the model classes don't always provide enough information to easily code features. As a result, additional special case code is needed around the model framework to handle all features. By improving the model classes instead, lots of that additional code can be avoided.
Changes to make:
-
Make PlcDerivedType
useful as reference to a type declaration. Currently it only has a name (the same as a type declaration that exists). (!863 (merged)) -
Add the type of a value to expression classes. Add type to PlcExpression
, all derived classes set it tonull
. This may cause need to temporarily handlenull
type values further down. (!875 (merged)) -
Cleanup the enumerations (currently tightly integrated with the type generator). (!875 (merged)) -
Add type to PlcEnumLiteral
(!875 (merged))
-
-
Cleanup the struct type (currently tightly integrated with the type generator). (!875 (merged)) -
Add type to PlcStructLiteral
(!875 (merged))
-
- Array type seems fine, mostly because we don't have type declarations for them.
-
Add type to PlcArrayLiteral
(!875 (merged))
-
-
Add type to PlcBoolLiteral
(!875 (merged)) -
Add type to PlcIntLiteral
(!875 (merged)) -
Add type to PlcRealLiteral
(!875 (merged)) -
Add type to PlcVarExpression
(!875 (merged)) -
Invent a function type. To be discussed. -
Create an overloaded type class ( ANY_INT
etc). To avoid getting generic types in expressions, derive this from a new super-type ofPlcType
. (!875 (merged)) -
Add types to function definitions, including generic types. (!875 (merged)) -
Compute result type for function applications (that is, resolve the generic types to concrete types). -
Add type to PlcFuncAppl
-
-
Finally, remove all temporary null
type handling code.
EDIT: Fixed markup of PlcStructLiteral
.
EDIT: "integrated with the type generator" rather than "integrated into the type generator".
EDIT: Less space between items (if one of them has an empty line, they all get more spacing).
Addresses #679