3
The initial version of the metrics tool should compute the
4
following metrics for each user-defined unit in the Context:
6
- the total number of statements in the code of the unit;
7
- the total number of declarations in the code of the unit;
11
Add to the initial version of the metrics tool computation for the
14
- the total number of simple statements (that is, statements
15
which do not contain some other statement as its subcomponent);
17
- the total number of compound statements (that is,
18
statements which do contain other some statement as its
21
- the total number of all the names explicitly declared in the
24
The subdirectory 'task_1' contains four files:
26
- actuals_for_traversing-pre_op.adb - actual Pre-Operation to
27
instantiate Traverse_Element, this file should replace the file
28
with the same name in ASIS Application Templates to get the
31
- unit_processing.adb - the modified version of the
32
unit_processing.adb file from the ASIS Application templates; the
33
modification consists of adding the calls to subprograms which
34
reset and print out the data structures used to collect metrics
35
values. This file is the same for the solutions of Task 1 and
38
- metrics_utilities.ads and metrics_utilities.adb - the package
39
Metrics_Utilities, contains the data structures to
40
collect metrics information and the procedures for printing this
41
information out and to reset these data structures before
42
processing the next unit.
44
The subdirectory 'task_2' contains three files:
46
- actuals_for_traversing-pre_op.adb - actual Pre-Operation to
47
instantiate Traverse_Element, this file should replace the file
48
with the same name in ASIS Application Templates to get the
49
solution for Task 2, it is the extended version of the same
50
file from subdirectory 'task_1', and it contains the code for
51
computing new metrics information, as required by Task 2.
53
- metrics_utilities.ads and metrics_utilities.adb - the package
54
Metrics_Utilities, updated to collect and output the new
55
metrics information as required by Task 2
60
To solve Task 1, you have to provide the real code for actual
61
Pre-Operation for Traverse_Element (this code should collect the
62
metrics information) and to add the calls to some procedures which
63
reset and which output the metrics values to the procedure providing
64
the general processing of a Compilation Unit (in the ASIS Application
65
Templates this is the Unit_Processing.Process_Unit). You have to
66
modify the general unit processing routine because you can only
67
collect the metrics information when traversing the unit structure,
68
and you have to reset the metrics data structures to the initial
69
values before starting the traversal, and you can print out the
70
metrics values only when the traversal is over.
72
The metrics to collect are very simple. In Pre-Operation, you have to
73
detect the kind of the Element being visited, and if it is a
74
statement or a declaration, you have to add 1 to the corresponding
77
Hints for Task 2 are given as comments in the solution for Task 1
78
(file task_1/actuals_for_traversing-pre_op.adb).
b'\\ No newline at end of file'