22using System . Linq ;
33using System . IO ;
44using Semmle . Extraction . Entities ;
5+ using System . Collections . Generic ;
6+ using Microsoft . CodeAnalysis . CSharp . Syntax ;
7+ using System ;
58
69namespace Semmle . Extraction . CSharp . Entities . Statements
710{
811 internal class GlobalStatementsBlock : Statement
912 {
1013 private readonly Method parent ;
14+ private readonly List < GlobalStatementSyntax > globalStatements ;
1115
12- private GlobalStatementsBlock ( Context cx , Method parent )
16+ private GlobalStatementsBlock ( Context cx , Method parent , List < GlobalStatementSyntax > globalStatements )
1317 : base ( cx , StmtKind . BLOCK , parent , 0 )
1418 {
1519 this . parent = parent ;
20+ this . globalStatements = globalStatements ;
1621 }
1722
1823 public override Microsoft . CodeAnalysis . Location ? ReportingLocation
@@ -27,16 +32,24 @@ public override Microsoft.CodeAnalysis.Location? ReportingLocation
2732 }
2833 }
2934
30- public static GlobalStatementsBlock Create ( Context cx , Method parent )
35+ public static GlobalStatementsBlock Create ( Context cx , Method parent , List < GlobalStatementSyntax > globalStatements )
3136 {
32- var ret = new GlobalStatementsBlock ( cx , parent ) ;
37+ var ret = new GlobalStatementsBlock ( cx , parent , globalStatements ) ;
3338 ret . TryPopulate ( ) ;
3439 return ret ;
3540 }
3641
3742 protected override void PopulateStatement ( TextWriter trapFile )
3843 {
3944 trapFile . stmt_location ( this , Context . CreateLocation ( ReportingLocation ) ) ;
45+
46+ for ( var i = 0 ; i < globalStatements . Count ; i ++ )
47+ {
48+ if ( globalStatements [ i ] . Statement is not null )
49+ {
50+ Statement . Create ( Context , globalStatements [ i ] . Statement , this , i ) ;
51+ }
52+ }
4053 }
4154 }
4255}
0 commit comments