A use is a qualified identifier that refers to a definition according to the scoping rules for names.
A use is a qualifying use if it qualifies another use. For example, in the following code
-
The expression
M.acontains the expressionM, which is a qualifying use of the moduleM. It qualifies the useM.a. -
The expression
M.ais not a qualifying use.
module M {
constant a = 0
constant b = M.a
}If a use u is not a qualifying use, then we say it is a non-qualifying use.
The set of definitions and non-qualifying uses in an FPP model induces a directed graph called the use-def graph. In this graph,
-
The nodes are the definitions.
-
There is an edge from each definition d to the definitions \$d_1, ..., d_n\$ corresponding to the non-qualifying uses \$u_1, ..., u_n\$ appearing in d.
For example, in the following code, the use-def graph has two nodes a and
b and one edge b \$rarr\$ a.
constant a = 0
constant b = aIn a legal FPP model, the use-def graph must be acyclic. For example, this model is illegal:
constant a = b
constant b = aThis model is also illegal:
constant a = aThis model is legal:
module M {
constant a = 0
constant b = M.a
}The use M appears inside the definition of M.
However, it is a qualifying use.
So long as the
use-def graph is acyclic, there is no
constraint either on the ordering of
definitions and uses within a
translation unit,
or on the distribution of definitions and uses among translation
units. For example, if the definition constant c = 0 appears anywhere
in any translation unit of a model M, then the use of c as a
constant value of type Integer is legal anywhere in any translation unit of
M. In particular, this model is legal:
constant b = a
constant a = 0The model consisting of two translation units
constant b = aand
constant a = 0is also legal, and the order in which the units are presented to the translator does not matter.
At certain points in the analysis, the analyzer may treat an element of the model as if it contained uses of one or more framework definitions. These uses are called implied uses. For example, a topology definition has implied uses when a dictionary is being generated.
Whenever an implied use is called out in this specification, the
definition being used must be available at the point of the implied
use.
If the definition is unavailable because it is hidden by another
definition in an inner scope, then an error occurs.
For example, this model is illegal, because the definition
M.FwSizeStoreType hides the framework definition FwSizeStoreType
at the point of the implied use
in the type string size 100:
module M {
type FwSizeStoreType = U16
type T = string size 100
}An error also occurs if the rules for resolving dot expressions cause an implied constant use to be resolved to a member of a struct value instead of a constant definition. For example, suppose this definition exists in the model:
constant A = { B = 0 }Then there is an error at any point where there is an implied use of the
constant A.B.
Here A.B does represent a constant value, but it does not represent
a constant definition, and so it is not a legal candidate
for an implied constant use.
This situation can occur because the dot syntax in FPP is overloaded
to mean both qualification and member selection.