Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
2fa35b9
WI #1260 Integrate Control Flow Graph
fm-117 Jun 2, 2020
3e5e84e
WI #1260 Clean up csproj files for CFG-related projects
fm-117 Jun 3, 2020
f314a98
WI #1260 Remove unused members
fm-117 Jun 3, 2020
5379e12
WI #1260 Use Container directly instead of a Dictionary
fm-117 Jun 3, 2020
c69364f
WI #1260 Use all tests
fm-117 Jun 3, 2020
66085bb
WI #1260 Use separate cs files for builder components
fm-117 Jun 3, 2020
d0b5737
WI #1260 Fix typos in comments
fm-117 Jun 3, 2020
3e058bb
Merge branch 'develop' into 1260_CFG_SemanticDomainLite
fm-117 Jun 5, 2020
67a45f0
WI #1267 Fixing nested builder properties from parent
fm-117 Jun 8, 2020
11b18e9
WI #1260 CurrentBlock renamed to OriginBlock in contexts
fm-117 Jun 10, 2020
fd28473
WI #1260 Type strongly contextual data of multi-branch context
fm-117 Jun 10, 2020
7955efc
WI #1260 Remove some useless code
fm-117 Jun 10, 2020
d4ae32b
WI #1260 Use HashSet instead of Dictionary to improve readability and…
fm-117 Jun 10, 2020
1bb5652
WI #1260 Rename test methods to match file names
fm-117 Jun 12, 2020
5ee80f5
WI #1269 Factorize test code
fm-117 Jun 12, 2020
8884e95
WI #1269 Remove unused Nist results
fm-117 Jun 12, 2020
476f4de
WI #1269 Match solution build configurations with project build confi…
fm-117 Jun 15, 2020
41f4d0d
WI #1269 Change test data to minimize warnings
fm-117 Jun 15, 2020
53b1ea1
WI #1269 Fix typo in test data
fm-117 Jun 15, 2020
63dcd80
WI #1269 Compare diagnostics produced during tests
fm-117 Jun 15, 2020
8a0a543
WI #1269 Move test results into input directory to keep all files in …
fm-117 Jun 15, 2020
ce087e1
WI #1267 Add new classes for Section/Paragraph/Sentence
fm-117 Jun 16, 2020
cb42157
WI #1627 Avoid using symbols in CFG builder
fm-117 Jun 16, 2020
ded6692
WI #1267 Rename ProcedureDivisionPartition to ProcedureDivisionRegion
fm-117 Jun 18, 2020
8b0f7a2
Merge pull request #1738 from TypeCobolTeam/1260_CFG_SemanticDomainLi…
fm-117 Jun 18, 2020
bf03bb7
WI #1267 Add analyzer classes and interfaces
fm-117 Jun 19, 2020
6ebbb6e
WI #1267 Rename NodeListener to INodeListener
fm-117 Jun 19, 2020
3221a26
WI #1267 Make NodeDispatcher static
fm-117 Jun 19, 2020
b9e8e38
WI #1267 Remove AbstractReport class
fm-117 Jun 22, 2020
4ff5faa
WI #1267 Merge INodeListener into IProgramClassBuilderNodeListener
fm-117 Jun 22, 2020
a5637f9
WI #1267 Add CfgBuildingMode option
fm-117 Jun 23, 2020
e2bf976
WI #1267 Make analyzer provider flow through compilation objects
fm-117 Jun 23, 2020
4bba5e5
WI #1267 Add analyzer results
fm-117 Jun 23, 2020
7f52974
Merge branch 'develop' into 1260_CFG_SemanticDomainLite
fm-117 Jun 25, 2020
7aa44f9
Merge branch '1260_CFG_SemanticDomainLite' into 1260_CFG_SemanticDoma…
fm-117 Jun 25, 2020
0f89c2b
WI #1267 Use single section/paragraph resolution mechanism for both C…
fm-117 Jun 26, 2020
bda590c
Merge branch '1260_CFG_SemanticDomainLite' into 1260_CFG_SemanticDoma…
fm-117 Jun 26, 2020
687f399
WI #1267 Remove unused error messages
fm-117 Jun 26, 2020
e6752c9
WI #1267 Add parent/children relationships directly on graph object
fm-117 Jun 26, 2020
c04ee70
WI #1267 Simplify CFG builder construction
fm-117 Jun 29, 2020
d6445de
WI #1267 Add missing statements in Enter/Exit/IsStatement
fm-117 Jun 29, 2020
27de692
WI #1267 Use single root block in CFG instead of multiple roots
fm-117 Jun 29, 2020
d5cf399
Merge branch '1260_CFG_SemanticDomainLite' into 1260_CFG_SemanticDoma…
fm-117 Jun 29, 2020
c6f9dbd
Merge pull request #1740 from TypeCobolTeam/1260_CFG_SemanticDomainLi…
fm-117 Jun 30, 2020
6014c43
WI #1627 Remove CfgMode enum
fm-117 Jun 30, 2020
6433dee
WI #1267 Collect graphs and diagnostics into a single builder
fm-117 Jul 1, 2020
07f3801
WI #1267 Avoid exposing internal builders used by root builder
fm-117 Jul 1, 2020
36c0493
WI #1267 Finalize integration of CFG/DFA as an analyzer
fm-117 Jul 2, 2020
6a3c8b2
WI #1267 Improve diagnostic message for out-of-bounds PERFORMs
fm-117 Jul 3, 2020
0ede890
WI #1267 #1448 Add unit test for procedure declaration order check in…
fm-117 Jul 3, 2020
17a6f4a
WI #1267 Add unit test for wrong ALTERs
fm-117 Jul 3, 2020
baaf1fb
WI #1267 Fix PERFORM THRU sentence resolution mechanism
fm-117 Jul 7, 2020
69643e1
WI #1267 Force block cloning in all PERFORM groups
fm-117 Jul 10, 2020
bcb9138
WI #1267 Add more PERFORM THRU tests
fm-117 Jul 10, 2020
916f17c
WI #1267 Use Warning instead of Error for premature PERFORM exit
fm-117 Jul 10, 2020
9074b49
WI #1267 Add tests for more exception conditions
fm-117 Aug 4, 2020
86f84be
WI #1267 Check MultiBranchContext status on node exit
fm-117 Aug 13, 2020
5f82586
WI #1269 Use source directory to allow autoreplace in tests
fm-117 Aug 14, 2020
4851ca3
WI #1267 Handle mutually exclusive exception conditions
fm-117 Aug 14, 2020
1b15533
Merge pull request #1741 from TypeCobolTeam/1260_CFG_SemanticDomainLi…
fm-117 Aug 21, 2020
15fa816
Merge branch 'develop' into 1260_CFG_SemanticDomainLite
fm-117 Aug 21, 2020
91e701d
WI #1267 Fix iterative and recursive PERFORMs graph building
fm-117 Aug 28, 2020
7b94976
WI #1267 Add tests for Extended graph building mode
fm-117 Sep 1, 2020
d1bf585
WI #1268 Avoid duplicate outgoing edges in recursive graphs
fm-117 Sep 17, 2020
88561a7
WI #1267 Fix recursion detection
fm-117 Sep 22, 2020
8425292
WI #1267 Remove unused Explicit CFG building mode
fm-117 Sep 28, 2020
cfc7b88
WI #1268 Avoid generating empty subgraphs in dot files
fm-117 Oct 13, 2020
c7745c6
WI #1268 Avoid PERFORM blocks relocation inside subgraphs
fm-117 Oct 15, 2020
c2a0f8e
Merge pull request #1765 from TypeCobolTeam/1260_CFG_SDLite_Iterative…
fm-117 Nov 9, 2020
7b4f5b3
Merge branch 'develop' into 1260_CFG_SemanticDomainLite
fm-117 Nov 9, 2020
75fb767
Merge branch 'develop' into 1260_CFG_SemanticDomainLite
fm-117 Nov 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions CLI/src/CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.Linq;
using System.Text;
using TypeCobol.Analysis;
using TypeCobol.CLI.CustomExceptions;
using TypeCobol.Codegen;
using TypeCobol.Compiler;
Expand Down Expand Up @@ -107,8 +108,9 @@ private ReturnCode Compile()
//Load intrinsics and dependencies, it will build the root symbol table
var rootSymbolTable = LoadIntrinsicsAndDependencies();

//Add report listeners
var reports = InitializeReports();
//Add analyzers
var analyzerProvider = new AnalyzerProvider();
var reports = RegisterAnalyzers(analyzerProvider);

//Normalize TypeCobolOptions, the parser does not need to go beyond SemanticCheck for the first phase
var typeCobolOptions = new TypeCobolOptions(_configuration);
Expand All @@ -121,7 +123,7 @@ private ReturnCode Compile()
foreach (var inputFilePath in _configuration.InputFiles)
{
var parser = new Parser(rootSymbolTable);
parser.Init(inputFilePath, typeCobolOptions, _configuration.Format, _configuration.CopyFolders);
parser.Init(inputFilePath, typeCobolOptions, _configuration.Format, _configuration.CopyFolders, analyzerProvider);
parser.Parse(inputFilePath);

//Collect results : parsing results, used and missing copies
Expand Down Expand Up @@ -229,30 +231,35 @@ private void CollectMissingCopies(IEnumerable<string> missingCopies)
}
}

private List<AbstractReport> InitializeReports()
private Dictionary<string, IReport> RegisterAnalyzers(AnalyzerProvider analyzerProvider)
{
List<AbstractReport> reports = new List<AbstractReport>();
var reports = new Dictionary<string, IReport>();
if (_configuration.ExecToStep >= ExecutionStep.CrossCheck)
{
//CFG/DFA
analyzerProvider.AddActivator(
(o, t) =>
CfgDfaAnalyzerFactory.CreateCfgDfaAnalyzer("cfg-dfa", _configuration.CfgBuildingMode));

if (!string.IsNullOrEmpty(_configuration.ReportCopyMoveInitializeFilePath))
{
Compiler.Parser.NodeDispatcher.RegisterStaticNodeListenerFactory(
() =>
analyzerProvider.AddActivator(
(o, t) =>
{
var report = new CopyMoveInitializeReport(_configuration.ReportCopyMoveInitializeFilePath);
reports.Add(report);
var report = new CopyMoveInitializeReport();
reports.Add(_configuration.ReportCopyMoveInitializeFilePath, report);
return report;
});

}

if (!string.IsNullOrEmpty(_configuration.ReportZCallFilePath))
{
Compiler.Parser.NodeDispatcher.RegisterStaticNodeListenerFactory(
() =>
analyzerProvider.AddActivator(
(o, t) =>
{
var report = new ZCallPgmReport(_configuration.ReportZCallFilePath);
reports.Add(report);
var report = new ZCallPgmReport();
reports.Add(_configuration.ReportZCallFilePath, report);
return report;
});

Expand Down Expand Up @@ -318,19 +325,23 @@ private void StoreGenerationException(string inputFilePath, GenerationException
generationExceptions.Add(generationException);
}

private void CreateReports(string inputFilePath, IEnumerable<AbstractReport> reports)
private void CreateReports(string inputFilePath, Dictionary<string, IReport> reports)
{
foreach (var report in reports)
{
string filePath = report.Key;
try
{
report.Report();
Console.WriteLine($"Succeed to emit report '{report.Filepath}'");
using (var writer = File.CreateText(filePath))
{
report.Value.Report(writer);
}
Console.WriteLine($"Succeed to emit report '{filePath}'");
}
catch (Exception exception)
{
Console.Error.WriteLine(exception.Message);
var generationException = new GenerationException(exception.Message, report.Filepath, exception);
var generationException = new GenerationException(exception.Message, filePath, exception);
StoreGenerationException(inputFilePath, generationException);
}
}
Expand Down Expand Up @@ -426,7 +437,7 @@ private void WriteCopiesFile(string copiesFilePath, IEnumerable<string> copies)
private ReturnCode AddErrorsAndComputeReturnCode()
{
/*
* Here we start with a Sucesss return code, then we check all diagnostics from
* Here we start with a Success return code, then we check all diagnostics from
* lowest to highest priority.
*/

Expand Down Expand Up @@ -507,7 +518,7 @@ private ReturnCode AddErrorsAndComputeReturnCode()
UpdateReturnCode(_intrinsicsDiagnostics.Select(dee => dee.Diagnostic).ToList());
}

//Always retrun MissingCopy when there is at least one missing copy because it could help the developer to correct several parsing errors at once
//Always return MissingCopy when there is at least one missing copy because it could help the developer to correct several parsing errors at once
if (_missingCopies.Count > 0)
{
returnCode = ReturnCode.MissingCopy;
Expand Down
4 changes: 4 additions & 0 deletions CLI/src/CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<Project>{4034cbc5-d3dc-45e5-81f2-605579e6b876}</Project>
<Name>Codegen</Name>
</ProjectReference>
<ProjectReference Include="..\..\TypeCobol.Analysis\TypeCobol.Analysis.csproj">
<Project>{c3250314-c22b-4eb6-9174-17d0791af7be}</Project>
<Name>TypeCobol.Analysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\TypeCobol\TypeCobol.csproj">
<Project>{7ac7a3e5-91f2-44bf-955d-86cc61375742}</Project>
<Name>TypeCobol</Name>
Expand Down
3 changes: 2 additions & 1 deletion Codegen/test/Performance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private static void Test(string path, bool forceFullParsing = false)
Path.GetDirectoryName(path),
new[] { ".tcbl", ".cbl", ".cpy" },
DocumentFormat.RDZReferenceFormat,
new TypeCobolOptions());
new TypeCobolOptions(),
null);
FileCompiler fileCompiler = new FileCompiler(compilationProject, fileName, false);
fileCompiler.CompileOnce();

Expand Down
24 changes: 24 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter0.cbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
 IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

PROCEDURE DIVISION.

A-PARA.
PERFORM DISPLAY 'IN A-PARA'
END-PERFORM.
PERFORM C-PARA THRU E-PARA.
ALTER B-PARA TO PROCEED TO E-PARA.
B-PARA. GO TO B-PARA.
DISPLAY 'IN B-PARA'.
GOBACK.

C-PARA.
DISPLAY 'IN C-PARA'.

D-PARA.
DISPLAY 'IN D-PARA'.

E-PARA.
DISPLAY 'IN E-PARA'.
END PROGRAM HELLO.

2 changes: 2 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter0.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--- Diagnostics ---
Line 10[12,16] <37, Warning, General> - Warning: ALTER should not be used
73 changes: 73 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter0.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
digraph Cfg {
compound=true;
node [
shape = "record"
]

edge [
arrowtail = "empty"
]
Block0 [
label = "{START|}"
]
Block1 [
label = "{A-PARA. Block1|}"
]
Block2 [
label = "{Block2| PERFORM\l}"
]
Block3 [
label = "{Block3| DISPLAY 'IN A-PARA'\l}"
]
Block4 [
label = "{Block4|}"
]
Block5 [
label = "{A-PARA. Block5|}"
]
Block6 [
label = "{Block6| PERFORM C-PARA THRU E-PARA\l}"
]
subgraph cluster_1{
color = blue;
label = "C-PARA";
Block17 [
label = "{C-PARA. Block17| DISPLAY 'IN C-PARA'\l}"
]
Block18 [
label = "{D-PARA. Block18| DISPLAY 'IN D-PARA'\l}"
]
Block19 [
label = "{E-PARA. Block19| DISPLAY 'IN E-PARA'\l}"
]

}
Block6 -> Block17 [style=dashed]

Block7 [
label = "{Block7|}"
]
Block8 [
label = "{A-PARA. Block8| ALTER B-PARA TO PROCEED TO E-PARA\l}"
]
Block9 [
label = "{B-PARA. Block9| GO TO B-PARA\l}"
]
Block16 [
label = "{E-PARA. Block16| DISPLAY 'IN E-PARA'\l}"
]
Block0 -> Block1
Block1 -> Block2
Block2 -> Block3
Block3 -> Block4
Block4 -> Block5
Block5 -> Block6
Block17 -> Block18
Block18 -> Block19
Block6 -> Block7
Block7 -> Block8
Block8 -> Block9
Block9 -> Block9
Block9 -> Block16

}
37 changes: 37 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter1.cbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
 IDENTIFICATION DIVISION.
PROGRAM-ID. ALTER1.
procedure division.
main section.

*> And now do some altering.
entrance.
ALTER front TO PROCEED TO atstart
GO TO front
.

*> Jump to a part of the front
front.
GO TO atstart.

*> the first part
atstart.
ALTER front TO PROCEED to middle
DISPLAY "This is the start of a changing front"
GO TO front
.

*> the middle bit
middle.
ALTER front TO PROCEED to atfinish
DISPLAY "The front progresses"
GO TO front
.

*> the climatic finish
atfinish.
DISPLAY "The front ends, happily ever after"
.

*> fall through to the exit
END PROGRAM ALTER1.

4 changes: 4 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter1.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--- Diagnostics ---
Line 8[12,16] <37, Warning, General> - Warning: ALTER should not be used
Line 18[12,16] <37, Warning, General> - Warning: ALTER should not be used
Line 25[12,16] <37, Warning, General> - Warning: ALTER should not be used
35 changes: 35 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter1.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
digraph Cfg {
node [
shape = "record"
]

edge [
arrowtail = "empty"
]
Block0 [
label = "{START|}"
]
Block1 [
label = "{ENTRANCE. Block1| ALTER front TO PROCEED TO atstart\l GO TO front\l}"
]
Block3 [
label = "{FRONT. Block3| GO TO atstart\l}"
]
Block5 [
label = "{ATSTART. Block5| ALTER front TO PROCEED to middle\l DISPLAY \"This is the start of a changing front\"\l GO TO front\l}"
]
Block7 [
label = "{MIDDLE. Block7| ALTER front TO PROCEED to atfinish\l DISPLAY \"The front progresses\"\l GO TO front\l}"
]
Block9 [
label = "{ATFINISH. Block9| DISPLAY \"The front ends, happily ever after\"\l}"
]
Block0 -> Block1
Block1 -> Block3
Block3 -> Block5
Block3 -> Block7
Block3 -> Block9
Block5 -> Block3
Block7 -> Block3

}
37 changes: 37 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter2.cbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
 IDENTIFICATION DIVISION.
PROGRAM-ID. ALTER2.
procedure division.
main section.

*> And now do some altering.
entrance.
ALTER front TO PROCEED TO atstart OF MAIN
GO TO front
.

*> Jump to a part of the front
front.
GO TO atstart.

*> the first part
atstart.
ALTER front TO PROCEED to middle of MAIN
DISPLAY "This is the start of a changing front"
GO TO front
.

*> the middle bit
middle.
ALTER front TO PROCEED to main::atfinish
DISPLAY "The front progresses"
GO TO main::front
.

*> the climatic finish
atfinish.
DISPLAY "The front ends, happily ever after"
.

*> fall through to the exit
END PROGRAM ALTER2.

4 changes: 4 additions & 0 deletions TypeCobol.Analysis.Test/BasicCfgInstrs/Alter2.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--- Diagnostics ---
Line 8[12,16] <37, Warning, General> - Warning: ALTER should not be used
Line 18[12,16] <37, Warning, General> - Warning: ALTER should not be used
Line 25[12,16] <37, Warning, General> - Warning: ALTER should not be used
Loading