A string variable declaration typed or untyped declares a variable whose value is a string. This variable may be used as a string expression. A string list variable declaration declares a variable whose value is a list of strings. The list may contain any number zero or more of strings. The same typed variable may not be declared more than once at project level, and it may not be declared more than once in any package; it is in effect a constant.
The same untyped variable may be declared several times. Declarations are elaborated in the order in which they appear, so the new value replaces the old one, and any subsequent reference to the variable uses the new value. However, as noted above, if a variable has been declared as a string, all subsequent declarations must give it a string value. Similarly, if a variable has been declared as a string list, all subsequent declarations must give it a string list value.
The simple variable name, for a variable in the current package if any or in the current project An expanded name, whose prefix is a context name. A context may be one of the following:.
The name of an existing package in the current project The name of an imported project of the current project The name of an ancestor project i. A variable reference may be used in an expression. Some attributes have values that are strings; others have values that are string lists.
There are two categories of attributes: simple attributes and associative arrays see section Legal project attribute names, and attribute names for each legal package are listed below. Attributes names are case-insensitive. Each simple attribute has a default value: the empty string for string-valued attributes and the empty list for string list-valued attributes.
The syntax of a simple attribute declaration is similar to that of an attribute definition clause in Ada. Attributes references may be appear in expressions. Associative array attribute references must have an argument that is a string literal. Note: this example is for illustration only. In practice, the project file would contain only one attribute declaration:. An associative array may be regarded as a function that takes a string as a parameter and delivers a string or string list value as its result.
Like untyped variables and simple attributes, associative array attributes may be declared several times. Each declaration supplies a new value for the attribute, and replaces the previous setting. An associative array attribute may be declared as a full associative array declaration, with the value of the same attribute in an imported or extended project.
In this example, Default must be either an project imported by the current project, or the project that the current project extends. If the attribute is in a package in this case, in package Builder , the same package needs to be specified. A full associative array declaration replaces any other declaration for the attribute, including other full associative array declaration.
Single associative array associations may be declare after a full associative declaration, modifying the value for a single association of the attribute. Here is a typical example:. The syntax of a case construction is based on the Ada case statement although there is no null construction for empty alternatives.
The case expression must a typed string variable. Each literal string must belong to the string type that is the type of the case variable. An others alternative, if present, must occur last.
The only constructions allowed in a case construction are other case constructions and attribute declarations. String type declarations, variable declarations and package declarations are not allowed.
The value of the case variable is often given by an external reference see section The source directories must contain at least one source file, unless the project file explicitly specifies that no source files are present see section The path name may be absolute or relative to the directory of the project file.
This directory must already exist, and be readable and writable. This directory must already exist, and be writable. This attribute's value is a string list. If the attribute is not given an explicit value, then there is only one source directory, the one where the project file resides. Source file names never include any directory information.
Each source file name must be the name of one existing source file in one of the source directories. In this case, only the file in the first directory is considered as an immediate source of the project file.
If the order of the source directories is not known statically, it is an error to have several files with the same source file name. Projects with no source files are useful as template packages see section To get this effect, P must import the projects that contain the needed source files.
As can be seen in this example, the syntax for importing projects is similar to the syntax for importing compilation units in Ada. However, project files use literal strings instead of names, and the with clause identifies project files rather than packages. Each literal string is the file name or path name absolute or relative of a project file. If a string is simply a file name, with no path, then its location is determined by the project path :.
If a relative pathname is used, as in. Any symbolic link will be fully resolved in the directory of the importing project file before the imported project file is examined. If a file with this extension is not found, then the file name as specified in the with clause no extension will be used. In the above example, if a file project1. A warning is issued if the name of the project file does not match the name of the project; this check is case insensitive.
Any source file that is an immediate source of the imported project can be used by the immediate sources of the importing project, transitively. However, this is not recommended, because if and when B ceases to import C , some sources in A will no longer compile. A side effect of this capability is that normally cyclic dependencies are not permitted: if A imports B directly or indirectly then B is not allowed to import A.
However, there are cases when cyclic dependencies would be beneficial. For these cases, another form of import between projects exists, the limited with : a project A that imports a project B with a straigh with may also be imported, directly or indirectly, by B on the condition that imports from B to A include at least one limited with. The difference between straight with and limited with is that the name of a project imported with a limited with cannot be used in the project that imports it.
In particular, its packages cannot be renamed and its variables cannot be referred to. An exception to the above rules for limited with is that for the main project specified to gnatmake or to the GNAT driver a limited with is equivalent to a straight with.
For example, in the example above, projects B and D could not be main projects for gnatmake or to the GNAT driver, because they each have a limited with that is the only one in a cycle of importing projects. This can be achieved through the project extension facility. A project extension declaration introduces an extending project the child and a project being extended the parent.
By default, a child project inherits all the sources of its parent. However, inherited sources can be overridden: a unit in a parent is hidden by a unit of the same name in the child. Inherited sources are considered to be sources but not immediate sources of the child project; see However, the package specification will still be found in the project Utilities.
A project is not allowed to import directly or indirectly at the same time a child project and any of its ancestors. In such cases, it is possible to create a virtual extension of entire hierarchy using extends all relationship. When the project is extended using extends all inheritance, all projects that are imported by it, both directly and indirectly, are considered virtually extended.
That is, the Project Manager creates "virtual projects" that extend every project in the hierarchy; all these virtual projects have no sources of their own and have as object directory the object directory of the root of "extending all" project.
It is possible to explicitly extend one or more projects in the hierarchy in order to modify the sources. These extending projects must be imported by the "extending all" project, which will replace the corresponding virtual projects with the explicit ones.
When building such a project hierarchy extension, the Project Manager will ensure that both modified sources and sources in virtual extending projects that depend on them, are recompiled. Create project A1 that extends A, placing modified P1 there: project A1 extends " Create project C1 that "extends all" C and imports A1, placing modified P3 there: with " Note that if a Library Project in the hierarchy is virtually extended, the virtual project that extends the Library Project is not a Library Project.
If both, then the command line value is used. The value of an external reference is obtained by means of the built-in function external , which returns a string value. For example:. In the form with one parameter, the function returns the value of the external variable given as parameter. If this name is not present in the environment, the function returns an empty string.
In the form with two string parameters, the second argument is the value returned when the variable given as the first argument is not present in the environment. An external reference may be part of a string expression or of a string list expression, and can therefore appear in a variable declaration or an attribute declaration.
For each such tool one can declare a package; the names for these packages are preset see section A package may contain variable declarations, attribute declarations, and case constructions. This attribute is an associative array, and its value is a string list. The index of the associative array is the name of a programming language case insensitive. This attribute indicates the switch or switches to be used with the corresponding tool.
Some packages also have another attribute, Switches , an associative array whose value is a string list. The index is the name of a source file. This attribute indicates the switch or switches to be used by the corresponding tool when dealing with this specific file. Further information on these switch-related attributes is found in After the prover has completed its analysis, you'll see a list of issues found in the source code of your application.
For the example above, the prover complains about an overflow check that might fail. This is due to the fact that, in the Acc procedure, we're not dealing with the possibility that the result of the addition might be out of range.
What do the tools do? Why is Abstraction Useful? Who is using Ada today? What is the future of the Ada technology? Is the Ada toolset complete? The actual step depends on your platform. Note that you can select any name for the main file.
If Emacs is used, the optional Ada mode may be helpful in laying out the program. The program text is a normal text file. We will assume in our initial example that you have used your editor to prepare the following standard format text file:. This file should be named hello.
0コメント